I want to validate a form.
How do I do that?
I have email,username,password as my fields. I don't want any of them to be NULL and password and confirm password should match.
Please help me out.
Thanks.
I want to validate a form.
How do I do that?
I have email,username,password as my fields. I don't want any of them to be NULL and password and confirm password should match.
Please help me out.
Thanks.
For stylish validation you can use jquery with help of nice styles.
refer this
http://www.webreference.com/programming/javascript/jquery/form_validation/
http://speckyboy.com/2009/12/17/10-useful-jquery-form-validation-techniques-and-tutorials-2/
Better to write your own validation rule , instead of using plugins, so that you can have better control on code Make it perfect with adding server side validation. Use ajax to looks better.
Javascript form validation is good for aggregate usability. You can display on the fly messages, pop-ups, animate, put colors...
But as mentioned, it should not replace the server-side validation. My recommendation as developer is to make the validation process on the server-side first, throwing messages, make as many UI effects as you can with CSS if you intend to use them, and just when you have a fully functional process you dive into javascript coding.
The most complicated part for beginners on javascript is learn how to access data properly. Of course, you can use jquery and make your work a lot easier, but if you do so, you won't learn much about the real javascript language.
This is also another advice for any language, before jumping on frameworks and time saving tools, you should first understand the language basics. This can make you a more solid developer.
About accessing javascript data, you will need to read about DOM (Document Object Model). Javascript and DOM are tied really close when developing for web.
You'll need to use either javascript or a server-side language such as PHP to validate your form.
If you are using the HTML5 doctype, then some preliminary validation can be done inline. The keyword required will make sure a field is not empty. You can also specify the type of content, such as email, url, date or number. Here's an example.
Note that HTML5 validation doesn't work in browsers that do not support it (IE6-8), but there is no harm and putting it in.
I would personally recommend to validate in PHP (if javascript is turned off). If this is all a bit confusing, then use a javascript solution http://docs.jquery.com/Plugins/validation .