Magento has some Default classes for validating form elements in frontend. We can make use of those existing
class names for our custom forms and reuse the client side validation code of Magento.
Let’s see a couple of examples from magento source code
1. Adding the required class to any field label will give the asterisk to be appear in red color indicating it is
the mandatory field
- <label for=“name” class=“required”><em>*</em></label>
2. If you want to make a field mandatory just add required-entry class in the input tag as shown below
- <input name=“name” id=“name” class=“input-text required-entry” type=“text”>
3. If you want to validate the field value entered by the user there is a seperate class available.