I have 3 fields and button:
<input type="text" id="a" />
<input type="text" id="b" />
<input type="text" id="c" />
<input type="button" id="d" />
<label for="all_fields" class="error" style="display:none;">Please fill exactly one field</label>
I want to use jquery validator plugin in order to validate that exactly one field filled with text. What is the best way to do it?
Working demo
for A / B / Ccase: http://jsfiddle.net/hfLwB/Behaviour: As long as one of the input field is set with nu,her value it will allow the calculation to happen, If all the 3 fields are empty it will thtourgh an error. You will also notice class
.at_least_oneand addMthod:require_from_group.Anyhoo code should speak better.
Good link: http://docs.jquery.com/Plugins/Validation
Hope it helps 🙂
HTML
Code