以下代碼中
<script type="text/javascript">
var validateForm;
var $table; // 父頁面table表格id
var $topIndex;//彈出視窗的 index
function doSubmit(table, index){//回呼函式,在編輯和保存動作時,供openDialog呼叫提交表單。
var mobileFlag = $(':radio[name="mobileFlag"]:checked').val();
$("#mobileFlag").val(mobileFlag);
if(validateForm.form()){
$table = table;
$topIndex = index;
$("#inputForm").submit();
return true;
}
return false;
}
$(document).ready(function() {
$("#value").focus();
var $inp = $('input:text');//獲取所有的輸入框(包括不可編輯)
$inp.bind('keydown', function (e) {
var key = e.which;
if (key == 13) {//13為enter鍵
e.preventDefault();//取消enter默認狀態
var nxtIdx = $inp.index(this) + 1;
var readonly = $(":input:text:eq(" + nxtIdx + ")").prop("readonly");//獲取下一焦點的狀態
while(readonly){//當下一焦點為不可編輯狀態時跳過改焦點
nxtIdx = nxtIdx+1;
readonly = $(":input:text:eq(" + nxtIdx + ")").prop("readonly");
if(!readonly){
break;
}
}
$(":input:text:eq(" + nxtIdx + ")").focus();
}
});
validateForm = $("#inputForm").validate({
submitHandler: function(form){
jp.loading();
$.post("${ctx}/em/emHouseOwner/save", $('#inputForm').serialize(),function(data){
if(data.success){
$table.bootstrapTable('refresh');
jp.success(data.msg);
}else{
jp.error(data.msg);
}
jp.close($topIndex);//關閉dialog
});
},
rules:{
mobile: {
required:true,
minlength:11,
isMobile:true,
remote: {
url:"${ctx}/em/emHouseOwner/check?oldMobile="+
encodeURIComponent("${equm.mobile}"),
cache:false
}
}
},
messages: {
mobile:{
required : "請輸入手機號",
minlength : "確認手機不能小于11個字符",
isMobile : "請正確填寫您的手機號碼",
remote: "手機號已存在"
}
},
errorContainer: "#messageBox",
errorPlacement: function(error, element) {
$("#messageBox").text("輸入有誤,請先更正。");
if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
error.appendTo(element.parent().parent());
} else {
error.insertAfter(element);
}
}
});
});
</script>
以上代碼中
1、$(":input:text:eq(" + nxtIdx + ")") 中的 eq(" + nxtIdx + ") 是什么意思?
2、var mobileFlag = $(':radio[name="mobileFlag"]:checked').val() 后的 .val() 是什么意思?
3、validateForm.form() 中的 .for() 是什么意思,沒有看查到這個函式定義的地方呀?
4、$(":input:text:eq(" + nxtIdx + ")").prop("readonly") 中的 .prop("readonly") 是什么意思?
5、validateForm = $("#inputForm").validate({}) 中的 $("#inputForm").validate({}) 是在什么時候會被執行?
uj5u.com熱心網友回復:
1、$(":input:text:eq(" + nxtIdx + ")") 中的 eq(" + nxtIdx + ") 是什么意思?=>第幾個":input:text",下標從0開始
2、var mobileFlag = $(':radio[name="mobileFlag"]:checked').val() 后的 .val() 是什么意思?
=>[name="mobileFlag"]的radio被選中項的值
3、validateForm.form() 中的 .for() 是什么意思,沒有看查到這個函式定義的地方呀?
=>所以我也沒看到
4、$(":input:text:eq(" + nxtIdx + ")").prop("readonly") 中的 .prop("readonly") 是什么意思?
=> 獲取其只讀屬性,設定:.prop('readonly',!0);
5、validateForm = $("#inputForm").validate({}) 中的 $("#inputForm").validate({}) 是在什么時候會被執行?
=>這應該是表單驗證插件,應該你上面:if(validateForm.form())這時就被執行了
然后:度娘或者其他什么,關鍵詞:jquery 中文手冊
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/200563.html
標籤:JavaScript
