2

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 1

2

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 . '"';
Sign up to request clarification or add additional context in comments.

2 Comments

Worked like a charm. So easy and can't believe I left it out. Thanks very much.
The required attribute is new in HTML5 it will work in latest browsers only it is recommended to validate

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.