Vasanth Natarajan

Vasanth Natarajan

  • 1.3k
  • 420
  • 46.9k

Javascript numeric validation

Jun 17 2016 5:30 AM
Numeric validation not working
 
function NumericOnly(event) {
//debugger;
      if (event.keyCode > 47 && event.keyCode < 58) {
            event.returnValue = true;
            return true;
      }
      else {
            event.returnValue = false;
            return false;
      }

}
suppose i entered a "v", it execute the else part but (event.returnVale=false;) value return to "v" i try some other options 

else {
      event.preventDefault();
      return false;
     }

even i used like this

   event.returnValue = null;

but my bad luck not working anyone know this help me...


Answers (2)