how to validate a required and numeric textbox using jquery?

EARNEM

New Member
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:\[code\] 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; }}\[/code\]Please help me.. i have tried the "[^0-9]" this also..
 
Back
Top