I have this HTML code:
<section id="variations_holder">
<input type="text" name="field1" class="pprice" />
<br/>
<input type="text" name="field2" class="pprice" />
<br/>
<input type="submit" />
</section>
And this is the code I'm using to handle validation:
$('#variations_holder input.pprice').each(function() {
$(this).rules('add', {
required: true,
number: true,
messages: {
required: "Debes introducir un precio de la variación",
number: "El precio de la variación debe ser un valor numérico o decimal"
}
});
});
And it works, however when the HTML looks like this (notice input has the same name's):
<section id="variations_holder">
<input type="text" name="field1" class="pprice" />
<br/>
<input type="text" name="field1" class="pprice" />
<br/>
<input type="submit" />
</section>
The same code stop working and cause this error:
TypeError: e.validator.methods[o] is undefined
How I can fix this issue?
This is derived from this question
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…