I have created one form.In that form,it put one textbox.That text box should take only integer not character or float.So I applied validation like this.Does it right?
var a = document.getElementById('textbox1').value;
var b = /^\d+$/;
If (a.search(b) == -1)
{
alert(Must be Interger);
return false;
}
Yes, that will work, unless it’s allowed to take a negative integer, in which case you need to add
-?(optional negative sign) before the\d