Validation, when dealing with form data, is the process of making sure you get the right information from your user, to send to your form processor.
Forms need to be validated so the information to be processed on the server, can be correctly processed. If the form processor (the file that the action attribute in your form tag points to) does not get the correct information, it can cause the script to break. This can do anything from cause an e-mail not to get sent, to slow down the server for other users, or even “break” the server deleting data.
We say “correctly” because, while it cannot check to see if the actual inputs are correct and accurate, it can check to see if they “look” correct. That is, to make sure the fields that cannot be left blank, are not left blank. Check to make sure someone entered numbers in numeric boxes, and validate email addresses. We cannot check to make sure the correct numbers or email address is entered.
However because of these two potential issues, it is wise to have the form processor on the server double check. Yes it requires more work, but it is better than someone trying to hack your system, or break a script due to bad inputs.
Let’s look at some different types of basic validation Dreamweaver allows for:
Adding Validation in Dreamweaver
Follow these steps to add your Dreamweaver Form Validation
- Place your cursor inside the form. Select the Form Tag in the tag selector.
Note: Make sure you do not select the button or any other form element.
- Select Tag Selector from the panel.
- Make sure Behaviors button is selected
- Click on the “+” to add a new behavior.
- Select “Validate Form” from the drop down menu.
From there, you can fill out the form as you best see fit.
(Dreamweaver) Validation Types
Most commonly, this is done by checking to see if there is any information there. For example, imagine a login form which doesn’t process correctly because the person failed to enter their password. This is often called checking for a null (or empty) value in programmer speak. In web form validation, we usually say it is a required field.
The field must be a number. This is often to ensure the correct type of data is entered. For example, if you ask for someone’s age, and they enter “young” it may not be accepted correctly.
This checks for a range of numbers. For example, if you are, like above, asking for a person’s age, you can assume that the value should be between 0 and 125. As you cannot be a negative value, and the odds of someone being over 125 are so small, it is not worth considering.
Validation in Action
When someone presses the submit button, it will validate against the form elements. If there is an error, it will not let them continue. If it passes validation, it will send the form information to the form processor as specified in the action tab.