My Requirement is to validate the ip ranges, I need to create a JavaScript function to accept only numeric and it must allow only between the range 0 to 255. If anything is ente
You need to validate the current value of the input, rather than the last key that was pressed:
Your function then just needs to be modified to: if(a < 0 || a > 255)
if(a < 0 || a > 255)