Monday, November 29, 2010

Phone Number Validation

I am taking a single Model.phone and breaking the input up into 3 inputs (area_code) – (prefix) – (suffix) so my question is how do I validate that? I can merge the data to get my Model.phone and run standard validation on that but how to get the message on error back to the view since Model.phone is not on the page?

 

My guess is validate each 3 if valid merge the data to get my Model.phone, but if any of the 3 are not valid (area_code) – (prefix) – (suffix) I only want 1 error message.

 

I do not want individual error messages for the 3 inputs since everyone knows a phone number is NUMBER if they want to waste their time putting in letters and junk well then go ahead, I only want to return 1 error message for the full Model.phone (wrong length, not empty stuff like that

 

Any ideas how to do this? Standard submit no js checking.

 

Thanks,

 

Dave

No comments: