Skip to content Skip to sidebar Skip to footer

Jquery Validation Not Working For Second Row In Table

Issue Details I am adding the rows dynamically. Code is inside JQuery steps. Jquery validation is working on first row in table but not on second row in table. I meant, when I cli

Solution 1:

Fix:

You need to specify 'required' as valid attribute in the data string you're building. Change this line:

data += "<tddata-th='Item ID#'><inputtype='text'id='item_no[" + rowid + "]'name='item_no[]'class='form-control required'/></td>";

to this:

 data += "<tddata-th='Item ID#'><inputtype='text'id='item_no[" + rowid + "]'name='item_no[]'class='form-control required=\'required\''/></td>";

Explanation:

I don't actually see any where in the jquery "append" documentation or the linked "htmlString" definition stating that attributes require values. This may very well be dependent on the doctype you're using, or may be specified somewhere else in the jquery documentation that I could not find.

Regardless, you may find that boolean attributes are not well-handled by certain libraries or browsers. Per the HTML spec https://www.w3.org/TR/html51/infrastructure.html#boolean-attribute you may include the value as well, and that will be handled more cleanly in many environments.

Post a Comment for "Jquery Validation Not Working For Second Row In Table"