Is it possible to validate a form so that if a tickbox is ticked, the user must fill in two text fields too.
Basically the form is for inputting potential vacancies to a database and has a section on the job type. this being either full or part time. depending which option they choose they need to fill in two other fields relating to their choice:
Full Time Option
- Weekly Hours
- Salary Per Annum
I'm not trying to be offensive, but that code is Internet Explorer-only. So try this one if you want it to span more web browsers.
Note: Pittimann's suggestion used.
alert("Please enter a value for \"Weekly Hours\"");
alert("Please enter a value for \"Salary Per Hour\"");
alert("Please enter values for \"Weekly Hours\" and \"Salary Per Hour\"");
<form name="theForm" onSubmit="return validateForm()">
Part Time:<input type="radio" name="time" checked> Full Time:<input type="radio" name="time"><br>
Weekly Hours: <input type="text" name="hours"><br>
Salary Per Hour: <input type="text" name="salary"><br>
<input type="submit" value="Submit">
Yah, and you might want to rename "Full Time:" to something else because the options "Full Time" and "Part Time" don't really answer the question of "Full Time?" if that made sense. It's hard to convey ideas sometimes. =|