开发者

Jquery, qunit selecting a substring of one classname

I am writing Qunit tests to test the validation engine of forms on our site. The structure of the form is standard with elements like the following:

<input id="name" class="validate[required,length[1,255]] amp_validation_error_field" type="text" value="" title="Name" name="name">

And I want to write a test in Qunit to verify that when or not the conditions are met (required or within the length 1-255) that a little warning jpeg pops up on the page.

I want to write t开发者_开发技巧his to be extensible so I want to select all elements on the page that have the validate keyword in the class but also be able to distinguish between the elements with different types of validation, for example all the elements on the page that are required, or required and with checking the length, etc etc. I don't know how to select and parse the classname basically. Thanks for your help.


A good start: http://jsfiddle.net/morrison/jgay7/

I didn't want to take all the work on myself, but that extension I wrote will get the values of the second validate parameter, in this case it would select [1,255] from length. It returns an array of arrays, where the inner array holds the values previously mentioned. This should be a good base for you to parse out what you want.

Comment if you need more direction.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜