How to validate a selected box with a button.
I'm not really sure how I would do this. I've looked at lots of tutorials on the web but they're all automatic validation for a whole form, i want a button to only validate when a user has the cursor in a selected input box. When they submit the button if it is empty it will say Please enter a number or something. I could do this for the whole form, but what I want is so that the selected text box is the only one that is validated.
The second validation rule is to compare it against a set of numbers, I don't really have a clue how to do this :(
In more depth:
Say there are 5 input boxes. 3 of them have a number in them and 2 are blank e.g. 4,3,"",7,""
What i would like to be able to do, is if I had a set of numbers that they should be e.g. 4,3,5,7,3 and for there to be a check button, that when submitted, would validate the selected input box. For example when the button is pressed if the selected box was empty it would say "please enter a number" (i would do this with an if else statement i think) e.g.
Something along those lines. But if the incorrect number was entered it would say "Incorrect number" (it checks against the 5 numbers 43573). I think i might have to do something with focus so that is just says whether that specific input box is correct or not? I also don't know how i would check against these 5 numbers? I would like to be able to do this with larger lengths of numbers too.
if (ch == '')
alert("Please Enter A Number");
<input type="text" size="2" value="4" id="N0">
<input type="text" size="2" value="3" id="N1">
<input type="text" size="2" value="" id="N2">
<input type="text" size="2" value="7" id="N3">
<input type="text" size="2" value="" id="N4">
<input type="button" onclick="input_check()" value="Check" />
Please help me, I can't find any tutorials covering anything like this :(