0
我有一個腳本,我希望「消息」錯誤在我的輸入框中顯示文本。
輸入表單的ID是「email」,但似乎我不能改變這種格式來允許除文本之外的任何其他內容,並且不改變表單的輸入?css表單驗證jquery
下面是代碼:
<script type="text/javascript">
$(document).ready(function(){
$("#myform").validate({
debug: false,
rules: {
email: {
required: true,
email: true
}
},
messages: {
email: "oh man!",
},
submitHandler: function(form) {
// do other stuff for a valid form
$.post('process.php', $("#myform").serialize(), function(data) {
$('.EmailList').html(data);
});
}
});
});
</script>
形式:
form name="myform" id="myform" action="" method="POST">
<div class="Email">
<label for="Email"></label>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="76%"><label for="Email"></label>
<input type="text" name="email" id="daEmail" size="30" value=""/> </td>
<td width="24%"><input type="image" name="imageField" id="imageField" src="images/Submit.png" /></td>
</tr>
</table>
</div>
</form>
怎麼樣你的CSS? –
其中是.EmailList類的HTML? – Swarne27
我通常會建議您不要在輸入欄中輸入或輸入消息,因爲您會替換/掩蓋原始用戶輸入。我會將該消息放置在該字段的下面或旁邊,或放置在氣泡中http://girliemac.com/blog/2011/11/28/html5-form-field-validation-with-css3/ – NightHawk