1
How can I validate multiple fields in the form where these fields are created dynamically?
Example:
<tr align="right">
<td style="font-size: 11px;"><b>Item 1 - Descontos:</b></td>
<td><input type="text" name="Desconto11" value="30" class="inputs" size="2" placeholder="%"></td>
<td><input type="text" name="Desconto12" value="5" class="inputs" size="2" placeholder="%"></td>
<td><input type="text" name="Desconto13" value="5" class="inputs" size="2" placeholder="%"></td>
<td><input type="text" name="Desconto14" value="" class="inputs" size="2" placeholder="%"></td>
<td><input type="text" name="Desconto15" value="" class="inputs" size="2" placeholder="%"></td>
</tr>
<br>
<tr align="right">
<td style="font-size: 11px;"><b>Item 2 - Descontos:</b></td>
<td><input type="text" name="Desconto21" value="30" class="inputs" size="2" placeholder="%"></td>
<td><input type="text" name="Desconto22" value="5" class="inputs" size="2" placeholder="%"></td>
<td><input type="text" name="Desconto23" value="5" class="inputs" size="2" placeholder="%"></td>
<td><input type="text" name="Desconto24" value="" class="inputs" size="2" placeholder="%"></td>
<td><input type="text" name="Desconto25" value="" class="inputs" size="2" placeholder="%"></td>
</tr>
I placed the field Descontox1 until Descontox5 where X is represented by the number of the item to which it is part.
- "Where Descontox1 cannot exceed the value of 30"
- "Where Descontox2 cannot exceed the value of 5 and can only be filled if Descontox1 is not empty."
- "Where Descontox3 cannot exceed the value of 5 and can only be filled if Descontox2 is not empty."
- "Where Descontox4 cannot exceed the value of 3 and can only be filled if Descontox3 is not empty."
- "Where Descontox5 cannot exceed the value of 2 and can only be filled if Descontox4 is not empty."
Remembering that the item can range from 1 to 999.
Could someone give an example of how to do this?
Just create a validation in the form’s Submit by checking by
class
inputs, rather than usingclass=inputs
for everyone, set a class for each group (no need to remove theinputs
if use for something else, may haven
classes, ex:class="inputs desconto1"
,class="inputs desconto2"
– Luis Henrique
I think with jquery you can. You can form validations in the property rule itself. Try using http://jqueryvalidation.org/
– dHEKU