
April 8th, 2004, 09:24 AM
|
|
Registered User
|
|
Join Date: Apr 2004
Posts: 7
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
PHP Form Validation - NEED HELP!!! please ;-)
Hi, Been working on this Order Form with Validation adding. Most of the validation rules work but when the validation doesn't work for the radio (buttons)  that i have within the order form.
Here's the code:
Code:
<title>Border Prints Order Form</title>
<!---Border Prints - Order Form Validate--->
<script>
<!--
function MM_findObj(n, d) { //v3.0
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}
function MM_validateForm() { //v3.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_valida teForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (val!=''+num) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '· '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) have occurred:\n\n'+errors);
document.MM_returnValue = (errors == '');
}
//-->
</script>
<center><form onSubmit='return validForm(this)' action=send.php method=post>
<font face=arial><font size=2><font color=darkblue>
Your Name:<br><input type=text name=name><br>
Your Email Address:<br><input type=text name=email><br>
Your Home Address:<br><input type=text name=address><br>
Your Postcode:<br><input type=text name=postcode><br>
Town / City:<br><input type=text name=towncity><br>
Choose mount colour:<br>
<input type=radio name="mountcolour" value= "green">green <input type=radio name="mountcolour" value= "cream">cream <input type=radio name="mountcolour" value= "fawn">fawn<br>
Choose mount size:<br>
<input type=radio name="mountsize" value= "10x8">10x8 <font size=1>(7.5 x 5.5 aperture)<font size=2> <input type=radio name="mountsize" value= "10x8">10x8 <font size=1>(7 x 5 aperture)<font size=2><br><br>
ENTER ORDER CODE:<br><font color= darkblue>
<input type=text name=subject value=''><font color=red><br><br><font color=darkblue>
<input type=submit value='Send order' onClick="MM_validateForm('name','','R','email','','RisEmail ','address','','R','towncity','','R','postcode','' ,'R','mountcolour','','R','mountsize','','R','subject','','R','');return document.MM_returnValue" style="font: normal 11px arial;"> <input type=reset value='Reset order' style="font: normal 11px arial";>
</center>
____
The mountcolour and mountsize - are both Radio Buttons, which doesn't seem to be recognized with my validation for sum reason
Any help would be greatfully received!! 
Last edited by dhouston : April 8th, 2004 at 03:24 PM.
Reason: Wrapping code in code tags for legibility's sake. Also moved question to appropriate forum.
|