我正在更新/設計網站,因此我使用了自定義提交按鈕來登錄表單。但是點擊提交時不帶任何有效輸入的造型完全改變其位置跳躍:jQuery驗證按鈕樣式在提交時發生變化
問題: http://test.theobaart.com/ReWork/loginIssue.png
真人版可以看出here,我使用的插件是jQuery驗證(jqueryvalidation。 ORG)
相關的代碼如下:
HTML:
<form id="createForm" method="post" action="create.php">
<label for="email">Email</label>
<input id="email" type="email" name="email"/>
<label for="password">Password</label>
<input id="password" type="password" name="password"/>
<input class="submit" type="submit" value="Login"/>
</form>
個
CSS:
/* Login form stuff */
form {
width: 100%;
margin: 0 auto;
}
label, input {
display: inline-block;
}
label {
width: 30%;
text-align: right;
}
label + input {
width: 60%;
margin: 10px 0 10px 4%;
}
/* Styling for input button */
input + input {
width: 20%;
max-width: 100px;
margin: 0 40% 10px 40%;
-webkit-border-radius: 0;
-moz-border-radius: 0;
border-radius: 0px;
font-family: Arial;
color: #a6afb9;
font-size: 21px;
background: #fffffff;
padding: 10px 10px 10px 10px;
border: solid #5f6f81 2px;
text-decoration: none;
}
input + input:hover {
background: #5f6f81;
text-decoration: none;
}
#loginForm div.error {
width: 100%;
text-align: center;
color: red;
}
超越進口jquery.validate.min.js
我也用下面的腳本:
$("#loginForm").validate({
errorElement: 'div',
rules: {
email:{required:true},
password: {required: true}
}
});
我有點送行無所適從,可能是什麼(所以爲什麼我問這裏)並且,據我所知,這不是一個普遍的問題,所以我一直無法找到任何與stackoverflow/google相關的內容。任何和所有的幫助表示讚賞!
非常感謝,
西奧
附:在我發佈之前,在最後一分鐘進行雙重檢查。這似乎只發生在底部字段(密碼)無效時。當它只是無效的電子郵件字段時,不會發生樣式更改。
你可以把一個jsfiddle放在一起嗎?我會說,當你在驗證中添加div時,你會搞亂這些樣式。順便說一句,使用現代瀏覽器,您可以在需要的字段中使用「required」,然後使用JS退回其他瀏覽器。 –
@Mark Robson。可以找到jsfiddle ** [這裏](http://jsfiddle.net/CQmGE/)**。我爲'errorElement'設置div的原因是因爲我希望可能出現驗證錯誤消息出現在下一行,而不是輸入元素之後。根據另一個stackoverflow問題([這裏](http://stackoverflow.com/questions/14666852/jquery-form-validation-css-of-error-label)加入'errorElement:'div''解決了這個問題。 –