I generated automatically with PHP form, for example:
<form id="stack">
<input type="text" name="aaa" pos="one"> <br />
<input type="text" name="bbb" pos="one"> <br />
<input type="text" name="aa3456" pos="two"> <br />
<input type="radio" name="group2" pos="one" value="Water"> Water
<input type="radio" name="group2" pos="one" value="Beer"> Beer<br>
<input type="radio" name="gvv" pos="two" value="Water2"> Water
<input type="radio" name="gvv" pos="two" value="Beer2"> Beer<br>
<INPUT NAME="options" pos="one" TYPE="CHECKBOX" VALUE="o1">
Option 1<BR>
<INPUT NAME="options" pos="one" TYPE="CHECKBOX" VALUE="o2">
Option 2<BR>
<INPUT NAME="options" pos="one" TYPE="CHECKBOX" VALUE="o3">
Option 3<BR>
<INPUT NAME="options2" pos="one" TYPE="CHECKBOX" VALUE="11">
111<BR>
<INPUT NAME="options2" pos="one" TYPE="CHECKBOX" VALUE="22">
222<BR>
<INPUT NAME="options2" pos="one" TYPE="CHECKBOX" VALUE="33">
333<BR>
<input type="submit" id="submit">
</form>
i dont know how is inputs and how the are named. I know only – they are attribute pos=”one”. In form can be also pos=”two” etc.
If they are attribute pos=”one” they must be not null.
How can i check this? In my example should be:
input text with name aaa & bbb should be not null
one input radio with name group2 must be checked – with value Water or value Beer.
minimum one input checkbox with name options shoud be checked.
minimum one input checkbox with name options2 shoud be checked.
How can i get all inputs where pos=”one” with jQuery? Maybe function each and filter? But how?
LIVE: http://jsfiddle.net/T8nNs/4/
EDIT: If some input is null/not checked i would like receive alert(‘error’).
You would grab the
posattribute, the input name, and the input val like this:From there, you can start doing your validations: