In the first part of this series I introduced various forms of validation including some best practices, the difference between client-side and server-side validation, the types of validation including separation and indications for required fields, correct format, and confirmation fields.
If you have never created web forms with validation then I invite you to follow along with this tutorial for creating a simple form that will perform validation of several different text fields and one text area field on a web page. I am utilizing Dreamweaver and its Validate Form Behavior in my example here; however, any web editing tool can be used to accomplish the same tasks with similar results using the code snippets provided.
In this simple form, no actual data will be submitted; we're only testing it for validation purposes.
Dating profile tips for men
Click in the Required checkbox under the Value: You can specify validation criteria for the remaining fields by highlighting each of the other field names listed in the "Named fields: If you're following this example then make the second field i. Test the validation routines by entering different values in the fields and clicking the Submit button. Also, try leaving one or more of the required fields blank and click the Submit button.
You should get popup error messages that describe what the problem is and what data is expected for each of the validated fields.
About web forms
Now, let's clean up the form a bit and add our instructions for the required fields with the following statement placed before the form area: Also add your asterisks to each of the required field names. In this tutorial and example we are only interested in the validation routines, and not where the actual form data will be submitted.
On the other hand, it may appear that nothing happens at all when the form submission is successful. However, for our purposes, the absence of any popup error message s upon form submission indicates that the form submission was indeed successful, i. The Validate Form dialog box will appear, and you can then make changes to the existing validation rules.
In the case where a single web page may be containing multiple forms, you must be certain that you've selected the proper field in the Named fields: If you're not careful when applying validation rules to fields in web pages containing multiple forms you may inadvertently add a validation rule to another existing form.
While this tool is great, it does have limited capability and functionality, so in a future installment of the series, I will demonstrate the use of another client-side validation tool known as the Check Form extension, available for Dreamweaver. It is a free, downloadable plug-in tool that allows for more advanced client-side validation for web forms.
Ryan has performed in a broad range of technology support roles for electric-generation utilities, including nuclear power plants, and for the telecommunications industry. He has worked in web development for the restaurant industry and the Federal g He has worked in web development for the restaurant industry and the Federal government.
Will London's start-ups stay or go? How Big Ass Fans went from cooling cows to a multinational tech powerhouse.
In addition, Dreamweaver can add...
Can Russian hackers be stopped? Here's why it might take 20 years. How driverless cars, hyperloop, and drones will change our travel plans. We deliver the top business tech news stories about the companies, the people, and the products revolutionizing the planet. Our editors highlight the TechRepublic articles, galleries, and videos that you absolutely cannot miss to stay current on the latest IT news, innovations, and tips.
Create a simple form If you have never created web forms with validation then I invite you to follow along with this tutorial for creating a simple form that will perform validation of several different text fields and one text area field on a web page. Create a simple form with client-side validation: Insert a form into the web page document Insert Form Form adding the following code: At this line inside the form type Name: Insert a text field into the form Insert Form Text Field.
Type Please enter an email address. Create a line break then hit Enter once to move the cursor insertion point one line down. Insert another text field Insert Form Text Field and in the name box enter EmailAddressField to name this field, which adds the following code: Hit Enter twice to place the cursor insertion point two lines below the Email text field you just created.
Type Enter a Comment: Insert a multi-line text field into the form Insert Form Text Area and in the name box enter CommentField to name this field, with 50 columns and 8 rows, adding the following code: Hit Enter twice to place the cursor insertion point two lines below the text area field you just created. Making sure your insertion point is still inside the form, insert a Submit button Insert Form Buttonand select Submit for the type selection from the pull-down menu, then name it SubmitButtonadding the following code: The entire form code should look like this: My Profile Log Out.