I am using ketchup plugin for my form validation. I have an a set of input element contained in a div that act as a prototype. That is, the said div is cloned and appended in a parent div when an ‘add’ button is pressed . for example that if I press it, say, 5 times the said prototype div will be cloned five times and appended to the parent div. Now, since I don’t want the elements in prototype divs to be validated, I am adding the ‘data-validation’ attribute in the input elements before appending the cloned div to the parent div. The problem is, apart from the add button, the cloning function is also called at the document.ready() function of jquery, it makes an AJAX call to the server , gets some data and appends the specified number of divs in parent.Since the validation.ketchup function (the function to valiate) is also called in document.ready, my validation are for some reason not working on these divs. but if I place a ‘check’ button and call the validation function on its click event, the validation works…but since validation does not work on document.ready, the messages are not shown on blur event, which is what I want…Can anybody give me any ideas??
Share
Well the form validation is an event that should be fired when the user interacts with a form, therefore should only be triggered on events such as form submit, textbox change, radio click etc
Put simply validation wouldn’t work on
$(document).readybecause there is nothing to validate. So put your validation checks in a function of some sort, or at least only call it when the user drives an event.