gpt4 book ai didi

javascript - 如何修复未捕获的类型错误 : Cannot read property 'settings' of undefined

转载 作者:行者123 更新时间:2023-11-28 06:11:06 25 4
gpt4 key购买 nike

我试图排除一个字段进行 jquery 验证,但问题是我遇到了如此可怕的错误。我的两个问题是如何排除 JQuery 验证器的一个字段以及如何修复 Uncaught TypeError: Cannot read property 'settings' of undefined 错误?

我正在使用这行代码:$('#datepicker').rules('remove', 'required');因为我想将其排除在验证之外。

这是我的 html 代码:

<tr>
<td>Product Code: <br>
<input disabled type="text" name="product_code_txt" id="product_code_addQty" required /></td>

<td>Date Purchased: <br>
<input type="date" name="date_txt" id="datepicker" class="date_addQty" required /></td>
</tr>

这是我的 Jquery 代码:

<script>
$(function() {
$('.addQty_link').click(function(){
var idnum = $(this).attr("value");
//alert(idnum);

addQuantity(idnum);

function addQuantity(idnum){
var addQty_dialog_form, formAddQty;
var rules = { txtName: { required: true } };
var messages = { txtName: { required: "Please enter name" } };

$('#datepicker').rules('remove', 'required'); // not working and it has an error

$("#addQty-entry-form").validate({
rules: rules,
messages: messages
});

addQty_dialog_form=$('#dialog-addQty-form').dialog({
resizable: false,
hide: 'fade',
autoOpen: false,
width:440,
minheight:350,
modal: true,
open: function(event, ui) {
$(this).dialog('widget').position({ my: 'top', at: 'top+120', of: window });
},
buttons: {
"Update": function() {
var reg=$("#addQty-entry-form").valid();
if(reg==false){
$('#addQty-entry-form .submit').click();
}
else if(reg==true){}
},
Cancel: function() {
addQty_dialog_form.dialog('close');
}
},
close: function() {
//formEdit[0].resetForm();
$("#addQty-entry-form").trigger("reset");
var validator = $( "#addQty-entry-form" ).validate();
validator.resetForm();
}
}).css('overflow','hidden');

addQty_dialog_form.dialog('open');

formAddQty = addQty_dialog_form.find( "form" ).on( "submit", function( event ) {
event.preventDefault();
// addUser();
});
return false;
}
});
});
</script>

最佳答案

只需添加忽略

   $("#addQty-entry-form").validate({
rules: rules,
ignore: '#date_addQty'
});

关于javascript - 如何修复未捕获的类型错误 : Cannot read property 'settings' of undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36383869/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com