Asp code validating a form

18 Mar

And when the page loads, the Java Script code will be executed (the user will see an alert box).It doesn't have to be anything in particular, but they can't leave the field blank.The Compare Validator and the Range Validator both compare things using equality comparisons (the is x=y type of thing). These pages will show how to process PHP forms with security in mind.Proper validation of form data is important to protect your form from hackers and spammers!

But it is quite clear that we can create more complex controls on submitted information.What makes the above snippet incredibly flexible is the fact that we can insert specific validation checks on every single field, giving us a wider customization.Then we need to set warning messages (one is generic, the second is specific to the email field), and a counter which will increase on errors count.If count Error is equal to zero (meaning no error found) we can submit the information.This control is a great little touch by the folks from Redmond and allows you to easily check if every validator on a page is satisfied or not instead of having to check them all individually.Here's a simple sample which utilizes a Required Field Validator to make sure the user enters something for a name: Before I call it a wrap on this lesson, I thought I should mention a cool feature of the validation controls.A database (and therefore an ASP data-driven site) is only as good as the data within it.