Using JQuery it is easy to validate numeric data in input fields.
Below code validates numeric input in the input type fields.
For this we only need to add .number as class for the input html tags in which we need to validate numeric data.
Below code validates numeric input in the input type fields.
For this we only need to add .number as class for the input html tags in which we need to validate numeric data.
$('input.number').blur(function () {
var value = $(this).val();
if (value == undefined || value == "") {
$(this).parent().find("span").remove();
return;
}
if (isNaN(value)) {
$(this).parent().find("span").remove();
$(this).parent().find("br").remove();
$(this).parent().append("</br><span
class='error'>Please Enter Number</span>");
}
});
Above blur event shows the Please Enter Number error message just after user moves cursor from input field.
Above blur event shows the Please Enter Number error message just after user moves cursor from input field.