Reputation: 23297
I'm trying to use an input validation script in jquery. Which executes on document ready event.
$(function(){
$("#cart").validationEngine();
});
Here's the form where I want to use it:
<form id="cart" name="cart_form">
<?php foreach($product as $prods): ?>
<tr>
<td><input type="text" id="qty_sel<?php echo $prods['PID']; ?>" name="qtysell[]" class="validate[required]"/></td>
<td><input type="text" name="subtotal" id="subtotal<?php echo $prods['PID']; ?>" class="validate[required]" readonly="readonly"/></td>
<?php endforeach; ?>
</form>
The above code doesn't work, but when I tried it in something simpler, it actually worked:
<form id="cart" name="a">
<input type="text" id="name" class="validate[required]"/>
</form>
Does this have something to do with another script which I have written which computes the subtotal from the given price and quantity. Or is it the ordering of the elements (table, form, input). Which causes the script to not work.
Upvotes: 0
Views: 234
Reputation: 1045
if you have some custom handler on the form's submit action such as
document.getElementById("formID").onsubmit = function(){
//custom code here
}
Then the validationEngine will not work ... Try adding your function to validationEngine.js
Upvotes: 1