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.
Dreamweaver provides some basic form validation using JavaScript. This means before the form is processed, the client’s browser checks to see if the form was filled out “correctly”.
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.
Dreamweaver’s Limitations
Dreamweaver’s validation cannot check on things like check boxes, radio buttons, or lists. Dreamweaver’s form validation only works on input tags with a type of “text”, i.e. text fields. It checks for validation issues on the client side using JavaScript. If someone has turned JavaScript off in their browser, then it will not be validated. However, this is a fairly rare occurrence in the modern world.
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
Required
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.
e-mail validation ensures that the form field has a well formed e-mail address in it. JavaScript cannot determine if the e-mail is a valid e-mail or not, just that someone has entered something that could be an e-mail address.
Numeric
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.
Numeric Range
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
Once you have filled out the settings, and saved it, Dreamweaver will handle the rest. They write all the JavaScript for you.All you have to do is upload it to the server.
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.
Creating Form Validation was originally found on Access 2 Learn