JQuery 유효성 검사를 사용하여 JQuery Mobile 웹 사이트에서 양식 필드의 유효성을 검사하기 위해 노력하고 있습니다. JQuery 유효성 검사는 서버에 ajax 호출을 보내 "원격"을 사용하여 사용자 입력의 유효성을 검사합니다.JQuery 유효성 검사 - 문자로 유효성 검사
처음으로 필드의 유효성을 검사 할 때 전체 단어가 입력 될 때까지 ajax 호출이 트리거되지 않는 이상한 현상이 있습니다. 그게 내가 원하는거야. 그러나 처음으로 유효성을 검사 한 후 나중에 포커스를 받으면 문자가 입력 될 때마다 ajax 호출이 트리거됩니다.
그것에 대해 알고 싶으십니까? 그게 버그 야?
내 코드는 다음과 같이
$("#form1").validate({
// Specify the validation rules
rules: {
"txt-username": {
required: true,
remote: {
url: "ManageAccessServlet?action=checkUsernameExist",
type: "get"
}
},
"txt-firstname": "required",
"txt-lastname": "required",
"txt-email": {
required: true,
email: true
},
"txt-password": {
required: true,
minlength: 6
}
},
// Specify the validation error messages
messages: {
"txt-username": "Username cannot be empty or it has been occupied in the system",
"txt-firstname": "Please enter your first name",
"txt-lastname": "Please enter your last name",
"txt-password": {
required: "Please provide a password",
minlength: "Your password must be at least 6 characters long"
},
"txt-email": "Please enter a valid email address"
},
submitHandler: function(form) {
form.submit();
}
});
HTML은 다음과 같습니다 :
<form action="SignupServlet" method="POST" id="form1">
<div data-role="collapsible" id="collapPersonalDetails" data-collapsed="false">
<h1>Personal Information</h1>
<div class="ui-field-contain">
<label for="txt-username">Username</label>
<input type="text" name="txt-username" id="txt-username" value="">
</div>
<div class="ui-field-contain">
<label for="txt-password">Password</label>
<input type="password" name="txt-password" id="txt-password" value="">
</div>
...
Ajax 요청을 트리거하는 데 사용하고 계신 것은 무엇입니까? keyup/keydown/form/button 제출 중입니까? –
버그 인 경우 Stack Overflow가 버그를보고 할 장소가 아닙니다. 그렇지 않으면 문제를 재현하는 코드의 최소 예를 살펴볼 필요가 있습니다. – Sparky
관련 HTML은 어디에 있습니까? – Sparky