I want to validate a textbox have numeric values using the following code, but i dont know the filter term there for numeric, my code is:
function validateRequiredNumeric(Control, msgInfo) {
var ControlId = $('#' + Control);
var msgInfoId = $('#' + msgInfo);
//testing regular expression
var a = ControlId.val();
var filter = /[^\d]/;
alert(a.length);
if (a.length != 0) {
if (filter.test(a)) {
msgInfoId.text('');
ControlId.css({ 'border': '1px solid green' });
return true;
} else {
//msgInfoId.css({ 'color': 'red', 'font-size': '12px', 'font-style': 'italic' });
msgInfoId.text("Numeric Onlydd fdf dfd");
ControlId.css({ 'border': '1px solid red' });
return false;
}
}
else {
//msgInfoId.css({ 'color': 'red', 'font-size': '12px', 'font-style': 'italic' });
msgInfoId.text("You can't leave this empty.");
ControlId.css({ 'border': '1px solid red' });
return false;
}
}
Please help me.. i have tried the "[^0-9]" this also..
/[^\d]/matches all except digits it's a negated character class