Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;
- }
- }
- var filter = /^d*$/;
- var a = Number($.trim(controlID)); //or parseInt($.trim(controlID))
- if (!isNaN(a)) {
- //a is valid number
- } else {
- //a is not a number or is empty
- }
Add Comment
Please, Sign In to add comment