also i have fix the code a bit but now i have seen that i have a problme with the line of the email
as if this line is empty the from still send it i only get a message if the user didn't enter a @
this is the code
so what to i need to add to make it also test if this field is empty
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1255" /> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>צור קשר</title> <script type="text/JavaScript"> <!-- function MM_findObj(n, d) { //v4.01 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[n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document); if(!x && d.getElementById) x=d.getElementById(n); return x; }
function MM_validateForm() { //v4.0 var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments; for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args); 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+' כתובת מייל לא חוקית.\n'; } else if (test!='R') { num = parseFloat(val); if (isNaN(val)) 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+' חסר\n'; } } if (errors) alert('זוהו השגיאות הבאות\n'+errors); document.MM_returnValue = (errors == ''); } //--> </script> <style type="text/css"> .text { -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; behavior: url(border-radius.htc); } </style>
</head>
<body style="color: #42B2AC; background-color: #000000">
<form action="mailer.php" method="post" name="form1" id="form1" style="margin:0px; font-family:Helvetica, Arial, sans-serif;font-size:20px; width:215px;" onsubmit="MM_validateForm('from','','RisEmail','subject','','R','verif_box','','R','message','','R');return document.MM_returnValue" dir="rtl" style="float: right;"> שם:<br /> <input name="name" type="text" class="text" id="name" style="padding:2px; border:1px solid #CCCCCC; width:180px; height:16px; font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;" value="<?php echo $_GET['name'];?>"/>
מייל:<br /> <input name="from" type="text" class="text" id="from" style="padding:2px; border:1px solid #CCCCCC; width:180px; height:16px; font-family:Verdana, Arial, Helvetica, sans-serif;font-size:14px;" value="<?php echo $_GET['from'];?>" dir="ltr"/>
<br /> נושא:<br /> <input name="subject" type="text" class="text" id="subject" style="padding:2px; border:1px solid #CCCCCC; width:180px; height:16px;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:14px;" value="<?php echo $_GET['subject'];?>"/>
<br />
כתוב את המספר שבתמונה:<br /> <input name="verif_box" type="text" class="text" id="verif_box" style="padding:2px; border:1px solid #CCCCCC; width:140px; height:16px;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:14px;"/> <img src="verificationimage.php?<?php echo rand(0,9999);?>" class="text" alt="verification image, type it in the box" width="50" height="21" align="absbottom" /><br />
<!-- if the variable "wrong_code" is sent from previous page then display the error field --> <?php if(isset($_GET['wrong_code'])){?> <div style="border:1px solid #990000; background-color:#D70000; color:#FFFFFF; padding:1px; padding-left:1px;width:155px;" class="text"> הקוד שהוזן אינו נכון</div> <?php ;}?>
המכתב: <textarea name="message" class="text" cols="6" rows="5" id="message" style="padding:2px; border:1px solid #CCCCCC; width:200px; height:100px; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:14px;"><?php echo $_GET['message'];?></textarea>
<input name="Submit" class="text" type="submit" style="margin-top:10px; display: block; border:2px solid #CCCCCC; width:100px; height:32px; font-family:Verdana, Arial, Helvetica, sans-serif; color: white ;font-size:20px; padding-left:2px; padding-right:2px; padding-top:0px; padding-bottom:2px; line-height:10px; background-color:#EA0071;" value="שלח מכתב"/> </form>