Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/456.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 被未捕获类型错误卡住:无法读取属性';设置';未定义的_Javascript_Jquery - Fatal编程技术网

Javascript 被未捕获类型错误卡住:无法读取属性';设置';未定义的

Javascript 被未捕获类型错误卡住:无法读取属性';设置';未定义的,javascript,jquery,Javascript,Jquery,我有这个错误 TypeError:无法读取未定义的属性“设置” 在JQuery中使用.rules()时,我进行了搜索,大多数问题都是通过使用setTimeout解决的,但在我的例子中,它不起作用 @Html.DropDownListFor(model => model.CountryId, new SelectList(ViewBag.Countries, "Value", "Text"), htmlAttributes: new

我有这个错误

TypeError:无法读取未定义的属性“设置”

在JQuery中使用
.rules()
时,我进行了搜索,大多数问题都是通过使用setTimeout解决的,但在我的例子中,它不起作用

@Html.DropDownListFor(model => model.CountryId, 
    new SelectList(ViewBag.Countries, "Value", "Text"),
    htmlAttributes: new
    {
         @readonly = Model.IsReadonly,
         @class = "form-control location select-search",
         data_val_required = string.Format(this.GCUResources("IsRequired"), this.GCUResources("Country")),
         data_placeholder = this.GCUResources("Country")
    })
@Html.ValidationMessageFor(model => model.CountryId, "", new { @class = "field-validation-valid validationspan validation-error-label" })
       
我还尝试在添加规则之前使用验证

$("form").validate();

可以添加HTML吗?您当前的代码不是,因此我们只能猜测问题所在。您的
.rules()
代码在哪里?文件准备好了吗?它是在
行中还是就在
行之前?您是否尝试使用(实质上)更长的setTimeout,例如5000?在尝试添加规则之前,您是否在表单上实例化了jQuery验证库?@evolutionxbox HTML是由
@HTML
@freedomn-m生成的,它解决了我的问题,非常感谢
$("form").validate();