我已经安装了一个不错的小 jQuery 邮件脚本,其中包含我不想要的必填字段(主题),并且想将其删除。首先,我只是简单地删除了 html,忘记了验证并得到了一个错误。然后我尝试删除验证是否<select>
选择了主题 (a) 的脚本部分,但出现错误,现在正在寻求帮助。这是脚本:
html:
<form id="contact-form" name="contact-form" method="post" action="submit.php">
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td width="25%" style="text-align:right;"><label for="name">Name</label></td>
<td width="65%" style="text-align:left;"><input type="text" class="validate[required,custom[onlyLetter]]" name="name" id="name" value="<?=$_SESSION['post']['name']?>" /></td>
<td width="10%" id="errOffset" style="text-align:right;"> </td>
</tr>
<tr>
<td style="text-align:right;"><label for="email">Email</label></td>
<td><input type="text" class="validate[required,custom[email]]" name="email" id="email" value="<?=$_SESSION['post']['email']?>" /></td>
<td> </td>
</tr>
<tr>
<td><label for="subject">Subject</label></td>
<td><select name="subject" id="subject">
<option value="" selected="selected"> - Choose -</option>
<option value="Question">Question</option>
<option value="Business proposal">Business proposal</option>
<option value="Advertisement">Advertising</option>
<option value="Complaint">Complaint</option>
</select> </td>
<td> </td>
</tr>
<tr>
<td valign="top" style="text-align:right;"><label for="message">Message</label></td>
<td><textarea name="message" id="message" class="validate[required]" cols="35" rows="5"><?=$_SESSION['post']['message']?></textarea></td>
<td valign="top"> </td>
</tr>
<tr>
<td><label for="captcha"><?=$_SESSION['n1']?> + <?=$_SESSION['n2']?> =</label></td>
<td><input type="text" class="validate[required,custom[onlyNumber]]" name="captcha" id="captcha" /></td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top"> </td>
<td colspan="2"><input type="submit" name="button" id="button" value="Submit" />
<input type="reset" name="button2" id="button2" value="Reset" />
<?=$str?> <img id="loading" src="img/ajax-load.gif" width="16" height="16" alt="loading" /></td>
</tr>
</table>
</form>
以及我想从中删除“主题”验证功能的脚本:
$(document).ready(function(){
$('#contact-form').jqTransform();
$("button").click(function(){
$(".formError").hide();
});
var use_ajax=true;
$.validationEngine.settings={};
$("#contact-form").validationEngine({
inlineValidation: false,
promptPosition: "centerRight",
success : function(){use_ajax=true},
failure : function(){use_ajax=false;}
})
$("#contact-form").submit(function(e){
if(!$('#subject').val().length)
{
$.validationEngine.buildPrompt(".jqTransformSelectWrapper","* This field is required","error")
return false;
}
if(use_ajax)
{
$('#loading').css('visibility','visible');
$.post('submit.php',$(this).serialize()+'&ajax=1',
function(data){
if(parseInt(data)==-1)
$.validationEngine.buildPrompt("#captcha","* Wrong verification number!","error");
else
{
$("#contact-form").hide('slow').after('<h1>Thank you!</h1>');
}
$('#loading').css('visibility','hidden');
}
);
}
e.preventDefault();
})
});
我试过删除上面代码中指示的区域。该脚本有一个“你是人类吗”的简单数学函数,删除代码后,我收到一条警告,指出简单数学的答案是错误的,尽管它是正确的。