I'm currently using the jquery validate rules plugin and I'm running into the following issue. While some of my input fields have static IDs. There are some fields that are dynamically generated so the ID isn't static. Unfortunately I don't have control of the ID generated. I can use a .each loop to get the IDs, but how could I pass the ID variable to the rules to validate. Is there a way to use a variable in the field name? If these fields where just required I would use a different method, however I need to do regex checks against the input.
$j('form').validate({
rules:{
txtFirstName: 'required',
txtLastName: 'required',
txtEmail: 'required',
randomIdFieldVariable: 'Regex check"
}
);
IDof the element... it can only use thename. But no, you cannot use a variable in place of the fieldnamewithin the.validate()method. You'll have to explain this better by constructing a more complete example if you want some suggested workarounds.