PDA

View Full Version : Radio button and other field form validation



mmace
10-19-2012, 08:22 AM
Hi, I'm struggling with some form validation, I have a very long and complicated form, the validation so far has been working fine.
I've just added a new section with a few radio button sections as well as dropdowns, text boxes etc.

an example of what I have is:



<input type="radio" name="NormEditInitial" value="NormEditInitial1" onclick = "showMessage(1)"/> I have a problem with a page<br />
<input type="radio" name="NormEditInitial" value="NormEditInitial3" onclick = "showMessage(3)"/> I have a problem with a picture or story<br />
<input type="radio" name="NormEditInitial" value="NormEditInitial4" onclick = "showMessage(4)"/> Article/Video not going to Web<br />
<input type="radio" name="NormEditInitial" value="NormEditInitial2" onclick = "showMessage(2)"/> Pictures are not transferring to Atex<br />

<div id="NormEdit1" style="display:none">
Publication Code: <select id="NormEdit1-PubCode" name="NormEdit1-PubCode" width="300" class="textboxstyle"><option selected value="">----- Select Title -----</option>
<?php include 'paper_title.php'; ?></select></div>

so, with the above, we have radio buttons, the first one reveals the div I have included (there's more to it, but that's all that's needed to show what I'm having trouble with.

Now, what I'm wanting to validate is that if the first radio button is selected (value="NormEditInitial1") then the dropdown list in the div must NOT be the first option (value="") but one of the other options in the list (all of which have a value).

now, an example of the other validations I have in the form (not including radio buttons) looks like the following:


if (document.all.ct.value == "TempReq")
{
if(document.all.temp1.value =="Shape Creation Request" && document.all.temp4.value.length <1)
{
alert("Please provide the full cluster number.");
return false;
}
The validation is in the head tag of the whole page (whole page is around 10,000+ lines long)
I've been told that document.all isn't the way to go, but I inherited the original form and just kept with it.
In the code above, "TempReq" is the name of a particular DIV which is one section of the form, the one I'm working on is called "support"

any help would be greatly appreciated

ajfmrf
10-19-2012, 04:43 PM
Please post a link to the problem code as well as the js,php and any other files used for this page.Make a txt file and post it so people can view the code(s) and check them out