views:

120

answers:

1

Hello friends!

I have a form having some text boxes, radio buttons, and select boxes. I write custom validation methods which i added using validator.addmethod. If user submitted this form keeping some or all fields empty then form should get submitted but if user enters data in text boxes then data should be alphabetic and should not contain special character and numbers. I write validation code for some text boxes for which the custom validation code as I mentioned above is as follows.

$.validator.addMethod('specialchar', function (value) { 
    return /^[^a-zA-Z]$/.test(value); 
}, 'First Name should not contain special characters.');
  1. *Now actually when user submits form with empty fields then error messages of above custom validation method is displayed for those textboxes to which above method is assigned *
  2. I think there is also problem in my regular expression which i can not able to spot. If my regular expression is right then is there any other method to add regular expression in JQuery i.e. lookahed regular expression.

Please help me on these two problems guys Thank You

A: 

Maybe something more like this:

/^[^a-zA-Z]{0,}$/

chprpipr
Thanks Chprpipr!I got some direction from your answer.I made some slight change in your solution and its working now as per i want. Thank You Very much
Param-Ganak