我有this网页,我正在使用jQuery验证插件。错误消息没问题,它们正确显示image(error.png)。但我有图像的问题,信号,输入是好的。我尝试用这段代码制作它,但我失败了。
success: function(label) {
var messages = new Array(
"Looks good!",
"You got it!",
"Ok!"
);
var num = Math.floor(Math.random()*3);
label.text(messages[num]).addClass("success");
}
所以我需要你的帮助,如何添加课程“成功”。
我的jQuery:
$(document).ready(function () {
$('#myform').validate({ // initialize the plugin
rules: {
email: {
required: true,
email: true
},
phone: {
required: true,
intlphone: true
},
jmeno: {
required: true,
tagcheck: true
},
psc: {
required: true,
psc: true
},
ulice: {
required: true,
minlength: 3
},
mesto: {
required: true,
minlength: 3
}
},
errorElement: "p",
messages: {
email: "<img src='images/error.png' alt='error'>",
phone: "<img src='images/error.png' alt='error'>",
jmeno: "<img src='images/error.png' alt='error'>",
psc: "<img src='images/error.png' alt='error'>",
ulice: "<img src='images/error.png' alt='error'>",
mesto: "<img src='images/error.png' alt='error'>"
},
submitHandler: function (form) { // for demo
alert('valid form submitted'); // for demo
return false; // for demo
},
});
});
我的CSS和HTML:
<style type="text/css">
.successhiden {
display:none;
}
.success{
display:block!important;
}
</style>
<div class="radek">
<label>Kontaktní email:</label><input type="email" name="email" class="pw">
<img src='images/done.png' alt='done' id="successMessage" style="display:none;" class="successhiden">
</div>
<div class="radek">
<label>Telefon:</label><input type="text" name="phone" class="pw">
<img src='images/done.png' alt='done' id="successMessage" style="display:none;" class="successhiden">
</div>
<div class="radek">
<label>Jméno a příjmení:</label><input type="text" name="jmeno" class="pw">
<img src='images/done.png' alt='done' id="successMessage" style="display:none;" class="successhiden">
</div>
<div class="radek">
<label>Ulice:</label><input type="text" name="ulice" class="pw">
<img src='images/done.png' alt='done' id="successMessage" style="display:none;" class="successhiden">
</div>
<div class="radek">
<label>Město:</label><input type="text" name="mesto" class="pw">
<img src='images/done.png' alt='done' id="successMessage" style="display:none;" class="successhiden">
</div>
<div class="radek">
<label>Psč:</label><input type="text" name="psc" class="pw">
<img src='images/done.png' alt='done' id="successMessage" style="display:none;" class="successhiden">
</div>
非常感谢你的时间和帮助。