开发者

Javascript Array in Class = How to make it valid

开发者 https://www.devze.com 2022-12-15 00:13 出处:网络
I am using this jQuery validation library on my website.It requires me to put the validation rules in the class part of the input tag.ie <input class=\"validate[required,custom[onlyLetter],length[0

I am using this jQuery validation library on my website. It requires me to put the validation rules in the class part of the input tag. ie <input class="validate[required,custom[onlyLetter],length[0,100]]" name="firstname" type="text" />

Now this causes me to end up with code in mine that looks similar such as:

<input type="text" 
       id="charfname" 
       name="charfname" 
       value=""  
       style="width: 300px;" 
       class="validate[required,length[3,20],custom[noSpecialCaracters]]" />

Which as you see has a [ and ] in the class name. So when I run the page through a validator I get the error:

character "[" is not allowed in the value of attribute "class"

How do I fix this to make it valid开发者_如何学C but still have the library work?

Thanks


Use some other method for initialization or use another script? Use an alternate attribute and a custom DTD for example. Or throw away the attribute based init system and use something else. Either way you have to modify the plugin's code. You cannot use "[" and "]" characters in a class name and any other combination implying them, period.

0

精彩评论

暂无评论...
验证码 换一张
取 消