Hello I have got a newsletter form. Not too sure what's wrong with the validation but when a user clicks the subscribe button without entering any values into the fields it submits anyway and takes you to the external url. Is there a way of making it so that both fields have to be filled in order for the subscribe button to work?
1 Answer
Just include the clause required="true" into the inputs that must be filled in the html, like this:
print '<tr><td>' . $myNameLabel . '</td><td><input required = "true" class="modns inputbox ' . $mod_class_suffix . '" type="text" name="m_name'.$unique_id.'" size="' . $nameWidth . '"';
2 Comments
Endô Fujimoto
Worked like a charm. So easy and can't believe I left it out. Thanks very much.
Domain
The required attribute is new in HTML5 it will work in latest browsers only it is recommended to validate