양식에 오류가 있어도 양식이 제출중인 Jquery 유효성 검사 양식에 문제가 있습니다.오류가있을 때 JQuery 유효성 검사 중지 양식 제출
여기에 다른 해결책을 확인했지만 어느 누구도 저에게 효과가 없었습니다. 내 양식에
// validate.js file
function setupFormsValidation(formName){
// validate
$(formName).validate({
onfocusout:false,
onkeyup:false,
onclick:false,
focusInvalid: false,
errorPlacement: function(error, element) {
if (element.parents('.inputgroup').length) {
error.insertBefore(element.parents('.inputgroup'));
element.parents('.inputgroup').addClass('error');
} else {
error.insertBefore(element);
};
},
showErrors: function (errorMap, errorList) {
// Code to process errors
});
// Code for initializing the form etc
}; //setupFormsValidation
, 여기에 코드입니다 : 나는에 중단 점을 지점이
<form action="thankyou.php" class="frmValidate" id="change-dept-form" method="post" name="change-dept-form">
<fieldset class="inlinelabels">
<legend><br /> Department name and code change information</legend>
<div class="row required" id="txt_current_dept_code_row">
<label class="required" for="txt_current_dept_code">Current department code (3 characters min, 4 characters max):</label>
<input class="required" data-min-length="3" id="txt_current_dept_code" name="txt_current_dept_code" required="required" type="text" />
</div>
<div class="row required" id="faculty2_row">
<label for="faculty2">Faculty:</label>
<select class="required" id="faculty2" name="faculty2" required="required">
<option value="">- Select -</option>
<option value="Arts">Arts</option>
<option value="Business">Business</option>
</select>
</div>
</fieldset>
<div class="row buttons">
<input id="mySubmit" type="submit" value="Submit" />
<input type="reset" value="Clear" />
</div>
</form>
<script src="../../assets/js/validate.js" type="text/javascript"></script>
$(document).ready(function(){
setupFormsValidation('#change-dept-form');
$("input[type='submit']").click(function(e){
$form = $('#change-dept-form');
if ($form.valid()){
alert('Test');
// need code to submit
} else {
alert('Show errors');
};
});
});
($ form.valid는()) {그리고 그 이후 어떤 코드를 실행하지 않는 경우 . 테스트 경고 또는 오류 표시 경고를 표시하지는 않습니다.
나는 그것을 시도했지만 양식은 여전히 제출된다. –
@Moxie C : 나는 그것이 불가능하다는 것에 두려워한다. return false가 실행되었는지 확인하십시오. –
나는 방화 광을 사용하여 디버그하고 코드에 중단 점을 넣었으며 코드의 경고 ('오류 표시) 부분에도 도달하지 않았습니다. –