我有一个接受电子邮件地址的模态表单。然后我验证这一点,如果无效,我想突出显示电子邮件框。但是使用 .css('background-color','red') 并没有做任何事情。我试过骆驼案'backgroundColor',但这没有任何区别。代码正在通过 else 路径,因为我收到了警报。这是代码:
$( "#dialog-form" ).dialog({
autoOpen: false,
height: 300,
width: 350,
modal: true,
buttons: {
"Send": function() {
if (validateEmail($('#email').val()))
{
var datastr = 'name=' + $('#name').val() + '&email=' + $('#email').val() + '&enquiry=' + $('#enquiry').val() + '&recip=' + eMail;
$.ajax({
type: "POST",
url: "email.php",
data: datastr,
cache: false,
success: function(html){
alert ("Email has been Sent");
}
});
$( this ).dialog( 'close' );
}
else
{
$('#email').css('background-color','red');
alert('Your Email Address is invalid');
}
},
Cancel: function() {
$( this ).dialog( 'close' );
}},
close: function() {
$( this ).dialog('destroy');
}
});
这里的表格:
<div id="dialog-form" title="Contact Computer Rep" style="display: none">
<form>
<div tal:condition="data/userlevel"><span>Your Name:</span><span tal:content="data/displayname"></span><br />
<span>Your Email Address:</span><span tal:content="data/mail"></span>
</div>
<fieldset>
<span tal:condition="not: data/userlevel">
<label for="name">Your Name</label>
<input type="text" name="name" id="name" value="" class="text ui-widget-content ui-corner-all" />
<label for="email">Your Email Address</label>
<input type="text" name="email" id="email" value="" class="text ui-widget-content ui-corner-all" />
</span>
<label for="enquiry">Your Enquiry</label>
<input type="text" name="enquiry" id="enquiry" value="" class="text ui-widget-content ui-corner-all" />
</fieldset>
</form>