Validating form fields with javascript

The form will include one text field called "Your Name", and a button.Our validation script will ensure that the user enters their name before the form is sent to the server. Try pressing the Send Details button without filling anything in the "Your Name" field.

validating form fields with javascript-56validating form fields with javascript-39

Let's expand this example with a more complex function that checks lots of form fields.Filling out forms on the web isn't the most exciting activity in the world, especially when you enter something the website doesn't expect.Most websites do a pretty poor job giving you feedback.Fortunately today's browsers have form validation features built in. I'm hoping this post exposes a couple more people to HTML5 form validation, or shows folks the current capabilities if they haven't looked at these features in a while.So let's dig into each one of these with an example.

Leave a Reply