I know that the following works very well:
<script LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT">
<!-- Hide script from older browsers
function validForm(ContactForm) {
for(j=0;j< ContactForm.plan_id.length;j++) {
el = ContactForm.plan_id[j];
if(el.checked == true){
return true;}}
alert("Please choose a plan type");
ContactForm.plan_id[0].focus();
return false
}// End hiding script --></script>
But since I am validating other stuff as well and the return true & return false are reversed as is standard code (see below) as is standard, but now I cannot get the radio check part right. It is alerting me in all cases whether checked or not.
<script LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT">
<!-- Hide script from older browsers
function validForm(ContactForm) {
if (ContactForm.rent_fname.value =="") {
alert("Please enter the renter's first name")
ContactForm.rent_fname.focus()
return false
}
if (ContactForm.phone_id.value =="99") {
alert("Please choose the phone you want to assign")
ContactForm.phone_id.focus()
return false
}
for(j=0;j<ContactForm.plan_id.length;j++) {
el = ContactForm.plan_id[j];
if(el.checked != true){
alert("Please choose a plan type");
ContactForm.plan_id[0].focus();
return false
}
}
return true
}
Note the line in bold above. Is it not posssible to check if a condition != true in Javascript?
<script LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT">
<!-- Hide script from older browsers
function validForm(ContactForm) {
for(j=0;j< ContactForm.plan_id.length;j++) {
el = ContactForm.plan_id[j];
if(el.checked == true){
return true;}}
alert("Please choose a plan type");
ContactForm.plan_id[0].focus();
return false
}// End hiding script --></script>
But since I am validating other stuff as well and the return true & return false are reversed as is standard code (see below) as is standard, but now I cannot get the radio check part right. It is alerting me in all cases whether checked or not.
<script LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT">
<!-- Hide script from older browsers
function validForm(ContactForm) {
if (ContactForm.rent_fname.value =="") {
alert("Please enter the renter's first name")
ContactForm.rent_fname.focus()
return false
}
if (ContactForm.phone_id.value =="99") {
alert("Please choose the phone you want to assign")
ContactForm.phone_id.focus()
return false
}
for(j=0;j<ContactForm.plan_id.length;j++) {
el = ContactForm.plan_id[j];
if(el.checked != true){
alert("Please choose a plan type");
ContactForm.plan_id[0].focus();
return false
}
}
return true
}
Note the line in bold above. Is it not posssible to check if a condition != true in Javascript?