jQuery驗證是不是在引導模式遠程內容的工作jQuery驗證不引導模式遠程內容的工作
有來自哪裏模式可以初始化加載內容
驗證工作都是好多個地方網頁,但它不工作時上遠程內容中的模態,其具有其上裝載
頁輸入<a href="javascript:void(0);" class="btn btn-circle btn-icon-only btn-default" title="Edit" onclick="user_editer('<?php echo $user['user_code']; ?>')">
<i class="icon-pencil"></i>
</a>
<div class="modal fade" id="ajax" class="edit_user_modalss"role="basic"aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<img src="../../theme/assets/global/img/loading-spinner-grey.gif" alt="" class="loading">
<span>
Loading... </span>
</div>
</div>
</div>
</div>
遠程模式的內容被加載模態上
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"> </button>
<h4 class="modal-title">Edit User</h4>
</div>
<div class="modal-body">
<form id="edit_user_form" class="edit_user_form" action="index.php" method="post">
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12" style="background:;margin-top:0px">
<div class="col-md-6 col-sm-12 col-xs-12" style="background:;margin-top:0px">
<div class="form-group">
<label for="phone">Name</label>
<input type="phone" name="user_name" class="form-control" id="user_name" placeholder="Enter Name" required maxlength="30" >
</div>
</div>
</div>
</div>
<input type="submit" id="edit_user_submit"name="edit_user_submit" class="btn blue" value="Save changes">
</form>
</div>
驗證
var form2 = $('#edit_user_form');
var error2 = $('.alert-danger', form2);
var success2 = $('.alert-success', form2);
form2.validate({
errorElement: 'span', //default input error message container
errorClass: 'help-block help-block-error', // default input error message class
focusInvalid: false, // do not focus the last invalid input
ignore: "", // validate all fields including form hidden input
rules: {
user_name: {
required: true,
minlength:2,
maxlength:30
}
},
messages: {
user_name: {
required: 'Email address is required',
minlength: 'Please enter a valid email address',
maxlength: 'This email address has already been used'
},
user_desig:"Select Authority",
},
invalidHandler: function (event, validator) { //display error alert on form submit
success2.hide();
error2.show();
Metronic.scrollTo(error1, -200);
},
highlight: function (element) { // hightlight error inputs
$(element)
.closest('.form-group').addClass('has-error'); // set error class to the control group
},
unhighlight: function (element) { // revert the change done by hightlight
$(element)
.closest('.form-group').removeClass('has-error'); // set error class to the control group
},
success: function (label) {
label
.closest('.form-group').removeClass('has-error'); // set success class to the control group
},
submitHandler: function (form) {
success2.show();
error2.hide();
form.submit();
}
});
模式初始化
function user_editer(user_code){
$('#ajax').modal({
show: true,
remote: 'user_edit_modal.php?user_code='+user_code
});}