放在哪里$ .validator.setDefaults({的onkeyup:假})来禁用MVC3的onkeyup远程attribue [英] Where to put $.validator.setDefaults({ onkeyup: false }) to disable MVC3 onKeyup for Remote attribue

查看:228
本文介绍了放在哪里$ .validator.setDefaults({的onkeyup:假})来禁用MVC3的onkeyup远程attribue的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到了如何禁用的onkeyup设置了MVC3远程验证有很多答案。我所看到的是响应进入这样的:

I have seen many answers for how to disable the onKeyup setting that the MVC3 Remote Validator has. The responses I have seen is to enter this:

$.validator.setDefaults({ onkeyup: false });

不过我不能肯定在哪里把这个。我试图把它放进自己的脚本块在我的布局视图的头,我试图把它在我的MVC3项目的jquery.validate.js文件。既不似乎工作。所以,我在哪里把这个剧本我的项目中,使其工作?

However I am not certain where to put this. I have tried putting it in its own script block at the head of my layout view, I have tried putting it in the jquery.validate.js file of my MVC3 project. Neither seems to work. So where do I put this script within my project to make it work?

推荐答案

您必须告诉code中的DOM被解析后执行。要做到这一点,只需敷code在$()函数:

You have to tell the code to execute after the DOM has been parsed. To do this, simply wrap the code in a $() function:

$(function() {
    $.validator.setDefaults({ onkeyup: false });
}

这将确保页面元素将加载,然后脚本会被执行,设置您的默认值。

This will ensure that the page elements will load, and then the script will be executed, setting your defaults.

这篇关于放在哪里$ .validator.setDefaults({的onkeyup:假})来禁用MVC3的onkeyup远程attribue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆