I have 3 text elements on a form which cause an Ajax function to be called (returning a series of dates).
The html looks like this;
<form id="seriesForm">
<input type=text id="days" value="" />
<input type=text id="weeks" value="" />
<input type=text id="months" value="" />
</form>
There is a button element that when clicked then picks up the values from the form and sends it to the backend using Ajax. If “days” has a value then the next x days are presented, if “weeks” the same day for the next x weeks is presented and so on.
If a user enters 2 in “days”, and then decides that it should be 2 in “weeks” and removes the 2 in “days” then this works fine, but if they forget to remove the first value, then nothing appears to happen.
So, I would like the entry in that form of text inputs to behave mutually exclusively.
I do not want to use radio buttons for this part of the job.
I already load jQuery (1.4.2) so can anyone tell me is there something already in existence in jQuery which will help me with this?
I face this situation in a couple of places so I’m really looking for something capable of taking some arguments, or maybe something which will detect a class mutually “mutually_exclusive” or some other clever ruse.
I googled around, and hope that mutually exclusive is the correct term, and that turns up loads of code for radios and checkboxes, but nothing about plain text inputs. So I am sure I can hack something around that stuff, and I know I could quite easily pop up an alerts saying “you cannot enter 2 values, remove one” but that defies my wish to make this as user-friendly as I can.
I am pretty sure I am not alone in doing this, and wondered - can anyone give me a leg up?
If not can you suggest some code/links to code.
Thanks