Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.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
Jquery 类的事件委派问题_Jquery_Validation - Fatal编程技术网

Jquery 类的事件委派问题

Jquery 类的事件委派问题,jquery,validation,Jquery,Validation,我想添加到我客户的旧CMS中 此jqery表单验证器需要插入一个类,如class=“validate[required,custom[onlyLetter],length[0100]]”以进行输入。 它根据我的需要将类添加到输入标记中。然而,当我通过js添加类时,它不起作用。我想这是因为事件授权 有人能帮我在这种情况下怎么办吗 提前感谢。如果addClass不起作用,可能是语法错误。。。也许: $(this).attr('class','validate[required,custom[onl

我想添加到我客户的旧CMS中

此jqery表单验证器需要插入一个类,如class=“validate[required,custom[onlyLetter],length[0100]]”以进行输入。

它根据我的需要将类添加到输入标记中。然而,当我通过js添加类时,它不起作用。我想这是因为事件授权

有人能帮我在这种情况下怎么办吗


提前感谢。

如果
addClass
不起作用,可能是语法错误。。。也许:

$(this).attr('class','validate[required,custom[onlyLetter],length[0,100]]');
可能有用吗

(编辑)


似乎验证器很可能只读取一次值,而不是连续读取。。。也许要确保在初始化验证库之前执行此操作?

谢谢。正如您所指出的,我只需要在验证库之前添加类。
var inputid = $(this).attr("id");

if(inputid=='navn'){
    $(this).removeClass().addClass('validate[required,custom[onlyLetter],length[0,100]] text-input');

}else if(inputid=='e-post'){
    $(this).removeClass().addClass('validate[required,custom[email]] text-input');
}else if (inputid=='telefon'){
    $(this).removeClass().addClass('validate[required,custom[telephone]] text-input');
$(this).attr('class','validate[required,custom[onlyLetter],length[0,100]]');