0
votes

I am working in asp.net mvc. I have a form in which there are 92 fields(textboxes). Each textbox coming from a xml bypassing some condition. I know this is hard to understand and interpret. In short, I want to validate my textboxes without decorating the Model with MVC Validation Attributes. I have used IClientValidatable but it requires Custom attributes which i dont want. I have used IValidatableObject but it does not have client side validation. For some reasons i can't directly call a Javascript or jQuery function to validate. What should i have to do to validate(client side) my one textbox for Phone number without decorating it with Attributes.

Thanks in advance...

1
May be javascript with regexp on textbox onchange will be useful?Frank59
more information is needed. what kind of validation? just required? regex? on form submit? provide a list or multiple examples and a scenarioDave Alperovich
Client side validation for Validating Phone Numbers. The behaviour should be runtime like if you entered a wrong phone number then onblur it show error message. (Not on form submit). I cant use the javascript directly because the script will tie with all the 92 textboxes then it will be hard to write a code which determine where the script should be enabled and where is not.Sometimes Code

1 Answers

0
votes

You can use the jquery validate plugin where in you can define the validation properties for each element in the page and this will be purely on client side and will not tie up the same criteria for all the text box elements in a page. Check here