I’m trying to clone input fields with JS and increment their id and name so I can validate them. Here’s an example:
<input type="text" id="work_company0" name="work[0][company]" />
<input type="text" id="work_company1" name="work[1][company]" />
<input type="text" id="work_title0" name="work[0][title]" />
<input type="text" id="work_title1" name="work[1][title]" />
So for the id, the regex would be:
/^(.*)(\d)+$/i
For id="work_company1", the match results in ["work_company1", "work_company", "1"] and I create the new ID by using match[1] + newID (work_company2).
What would be the regex for the name to get a similar match?
Do you mean this?
hope this makes sense.