Hi all,
Hope someone can help, I'm using the malsup jquery form plugin which is great but I'm having trouble trying to validate with it.
My problem is that I have multiple forms which the same input fields, so I can submit each form separate with Ajax each has its own id updateAddress1, UpdateAddress2 ect.. For this reason I've binded each form seperatly.
php code:
for($i=1; $i<=$deliveryAddress; $i=$i+1)
{ echo "$('#updateProduct" . $i . "').ajaxForm(options);" }
This works to submit each form, but I have added a beforeSubmit: to validate. I can get it to validate the current form fine, what I want to do is return a response to that specific form, such as address complete, or highlight blank inputs, how can I do if each for has a different id?
javascript code(check whether all fields contain text)
function showRequest(formData, jqForm, options) {
for (var i=0; i < formData.length; i++) {
if (!formData[i].value) {
// NEED TO SHOW ERROR ON CURRENT FORM
return false;
}
// CURRENT FORM ADDRESS IS OK!
}
return true;
}
Is their an easy way to bind the jquery form to all forms with the same id then update an element within that form to say the address is complete?
I did find this code which looked like I could bind validation by adding a class to the form, but when I do that, the ajaxsubmit stops working
$(document).ready(function() { $(".validation").each(function() { $(this).validate(); }); });
I really hope someone out there is able to help - many thanks in advance!
Simon.