If you want to use the validation functionality provided with Dynamicweb eCommerce in combination with custom JavaScript validation then the validation in the JavaScript will be run first and then the built-in validation engine secondly.
 |
Dynamicweb eCommerce have previously included JavaScript validation in the functions.js file located in the folder /Templates/eCom folder. If you only want to use the validation engine described above, you will need to remove or comment out the validation code in the top of the file. In the default functions.js file delivered with Dynamicweb eCommerce, the code has been commented out.
|
Consider the following example:
- A custom JavaScript validates the name and e-mail fields in step 2.
- The validation engine in Dynamicweb eCommerce validates the name, e-mail, address and phone number fields in step 2.
The validation and the corresponding error messages will be shown in the following way when going from step 2 to step 3 without entering information in the fields mentioned above:
- The JavaScript will check for incorrect information and error messages will be displayed if incorrect information occurs.
- When the name and e-mail field has been filled out and the customer proceedes to step 3 then the validation engine will check the fields. The engine will check for remaining rules for the name and e-mail field plus the address and phone number fields. Error messages entered under the paragraph settings will then be displayed if the fields still does not validate.
- When all rules validate both in the JavaScript and the validation functionality in Dynamicweb eCommerce, the customer can proceed to step 3.
 |
If you are using both JavaScript validation and the validation functionality in Dynamicweb eCommerce, you should be aware not to have contradictory validation for the same field, such as the field must be larger than 5 characters (required in the JavaScript) but also less than 5 characters (required in the built-in validation functionality).
|