I need to develop an application windows phone 7. And for obvious reasons I have to validate my forms.
I usually program in WPF and uses the principle of ValidationRule. But I can not find the same principle in windows phone 7.
Hence my question, how to create a form validation.
Form validation is a “technical process where a web-form checks if the information provided by a user is correct.” The form will either alert the user that they messed up and need to fix something to proceed, or the form will be validated and the user will be able to continue with their registration process.
Form validation generally performs two functions. Basic Validation − First of all, the form must be checked to make sure all the mandatory fields are filled in. It would require just a loop through each field in the form and check for data.
Using the email type, we can check the validity of the form field with a javascript function called… checkValidity() . This function returns a true|false value. checkValidity() will look at the input type as well as if the required attribute was set and any pattern="" tag .
Windows Phone doesn't support form validations out of the box.
Here's a blog post that describes how to roll a custom control to implement validation rules.
The way I would handle this in one of my own apps would be to put the validation logic in my model class and create an IsValid
property on the model. The model class would also have an Error
property with an error message describing the validation issue. My UI layer would call myModel.IsValid
, and display the error message if something was wrong.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With