0

i am creating a sign up form in which there are 7 required fields, i want to validate those required fields using javascript. i tried if-else block but its troublesome and confusing, is there any other way to do those required field validation in javascript, without using jQuery validation library?

Thanks.

1
  • There is but how easy it is depends on what type of field you have, if they are all text fields it's easy, if you have select and others it gets more complicated as you need to grab the value different way depending on the field type Commented Apr 13, 2012 at 22:27

3 Answers 3

1

If you are using html5 you may want to take a look into the newer input tag attributes.

http://www.w3schools.com/html5/att_input_required.asp

Sign up to request clarification or add additional context in comments.

Comments

0

see http://www.w3schools.com/js/js_form_validation.asp

and http://php.net/manual/en/filter.examples.validation.php

both sites have form validation made easy, PHP's is built-in

Comments

0

You can use the pattern attribute which is a regular expression that is checked against the content of the field to determine whether or not the field is valid. Also, to make sure that the field is not empty, you can use the required attribute.

Comments

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.