我正在尝试制作联系表格,并且需要对 input type=text 进行验证,但是,它似乎有一些错误,我找不到。你能帮助我吗?这是代码:
<td>
Name*:<input type="text" name="name" id='name2' class="name1" />
</td>
<td>
Email*:<input type='text' name="email" class="email1" id='email2'/>
</td>
</tr>
<tr>
<td colspan="2" rowspan="2">
Message*: <br />
<textarea name='msg' style="float:right;" class="msg1" id='msg2'>
</textarea>
</td>
和这里:
<?PHP
$nml = strlen($_POST['name']);
$eml = strlen($_POST['email']);
$msgl = strlen($_POST['msg']);
if(isset($_GET['sent'])) {
if($nml<1) {
if($eml<1) {
if($msgl<1) {
exit("<script>document.getElementById('name2').style.borderColor='red'; document.getElementById('email2').style.borderColor='red'; document.getElementById('msg2').style.borderColor='red';</script><center><font color='red'>Name*, Email* and Message* fields are required</font></center>");
}
exit("<script>document.getElementById('name2').style.borderColor='red'; document.getElementById('email2').style.borderColor='red';</script><center><font color='red'>Name* and Email* fields are required</font></center>");
}
exit("<script>document.getElementById('name2').style.borderColor='red'; <center><font color='red'>Name* field is required</font></center>");
}
if($eml<1) {
if($msgl<1) {
if($nml<1) {
exit("<script>document.getElementById('email2').style.borderColor='red'; document.getElementById('name2').style.borderColor='red'; document.getElementById('msg2').style.borderColor='red';</script><center><font color='red'>Email*, Name * and Message* fields are required</font></center>");
}
exit("<script>document.getElementById('email2').style.borderColor='red'; document.getElementById('msg2').style.borderColor='red';</script><center><font color='red'>Email* and Message* fields are required</font></center>");
}
exit("<script>document.getElementById('email2').style.borderColor='red';</script><center><font color='red'>Email* field is required</font></center>");
}
if($msgl<1) {
if($nml<1) {
if($eml<1) {
exit("<script>document.getElementById('msg2').style.borderColor='red'; document.getElementById('name2').style.borderColor='red'; document.getElementById('email2').style.borderColor='red';</script><center><font color='FF0000'>Message*, Name* and Email* Fields are required</font></center>");
}
exit("<script>document.getElementById('msg2').style.borderColor='red'; document.getElementById('name2').style.borderColor='red';</script><center><font color='FF0000'>Message* and Name* Fields are required</font></center>");
}
exit("<script>document.getElementById('msg2').style.borderColor='red';</script><center><font color='FF0000'>Message* Field is required</font></center>");
}
}
?>
请帮我修复它,我尝试了很多次,但我无法修复它。对我来说太难了