hi.. someone kindly gave me the below script that makes sure one of my radio buttons is checked before the user can press submit.. my question is this..
is there a basic procedure that i can use that will place rules on the other form inputs..
so if they do not choose an item from a drop down.. or do not write text in a textbox.. and so on.. also can all of these commands be placed in one function.. as opposed to wrting a separate function for each part of the form validation..
if someone could show me a general snippet that is not to hard to manipulate i would be very grateful.. thanks..
is there a basic procedure that i can use that will place rules on the other form inputs..
so if they do not choose an item from a drop down.. or do not write text in a textbox.. and so on.. also can all of these commands be placed in one function.. as opposed to wrting a separate function for each part of the form validation..
if someone could show me a general snippet that is not to hard to manipulate i would be very grateful.. thanks..
Code:
<script type="text/javascript">
<!--
function doRedirect()
{
var groupValue;
var myOption = -1;
for (i=document.form.r1.length-1; i > -1; i--) {
if (document.form.r1[i].checked) {
groupValue = document.form.r1[i].value;
myOption = i;
}
}
if (myOption == -1) {
alert("You must select an option. \n e.g: Take me to Heathrow");
return false;
}
else {return true;}
}
-->
</script>