Numbers Only Please

[Total: 0    Average: 0/5]

This script validates form input to be numbers.

Body Code:

Enter 9 numbers: <input type=text name=numbers>
<input type=button onclick=verify(this.form) value="verify">
function verify(_f)
  var _x=_f.numbers.value;

  var _exp = new RegExp(/^d+$/);
  var _test=_exp.test(_x);

  if(_x.length!=9)alert("length not correct");
  else if(!_test)alert("non digits found");
  else alert("this value is okay.");

Times Viewed: 4

Leave a Reply

Your email address will not be published. Required fields are marked *