The validation for the radio buttons is returning a false positive when no radio button is checked. Sooo...how can I make sure the user is selecting one of the radio button selection?
another way to do this is:
function validate()
{
f.=document.formName;
if(f.required-Phone.value == "")
{
alert("a phone number is required");
f.required-Phone.focus();
}
do this for all form items for a text areas then for the checkboxes
not sure what to do with the JS. but you could set one of the radio buttons as a default value and then at least something is selected and cannot return a nukk value. the only danger in this is if someone skips this part of the form, then their information getts misinturpreted.
the JS goes where it usualy goes inside the <script> tags </script>
I tested the code before i submitted it so it does work at least on my debugger.
With the radio buttons much like checkboxes, testing for its value doesn't accoumplish much. The DOM places radio button groups into an array in the same order that they appear in the form so checking all buttons in a group is neccessary to determine which one is checked. Luckly in this case there was only two to check.
thanks to my handy dandy JS book I always keep handy.
A question to phpScott. In your reply, could you explain how the first statement (f.=document.formName) works ? Does it copy the entire form object onto the f. variable so that you can easely test it ?
Thanks,
Luca
Thanks for the replies! I've found that JS was trying to subtract also, and the form is being sent to another script, that I didn't write, for processing and so is relying on the variable names staying the same. I'm going to have to try to get to that script and make those changes, but that'll work.
Lovasco, what setting the f variable to document.formName does is it basically truncates the first two levels of the Document Object Model, so you have to use less code throughout the rest of your checking. So, instead of having to check this everytime:
Yes Crashin that is exactly why i wanted to set that variable. If there is a way that I can get around typing I will try to do it. What is happing is that you are creating a object called 'f' in this case from all the elements of the form and using js dot notation to now access that objects properties.
phpScott
see even if you didn't know it you are kinda sorta doing object orientated programming.