vchris Posted December 14, 2006 Share Posted December 14, 2006 function validateForm(thisForm) { var extraValue = thisForm.extra.value; if(extraValue > 0) { for(i = 1; i <= extraValue; i++) { if(thisForm.extraEmail_i.value == '') { alert('Extra e-mail ' + i + ' is required.'); } } }} As you can see I have thisForm.extraEmail_i.value. I want to validate many text inputs I have (0-8). So basically all I want is the _i to be evaluated by JS (take the value of i in the loop). In CF you add #, how can that be done in JS? Link to comment Share on other sites More sharing options...
pulpfiction Posted December 14, 2006 Share Posted December 14, 2006 Try this....var str;for(i = 1; i <= extraValue; i++) { str = eval("thisForm.extraEmail_"+i); if(str.value == '') { alert('Extra e-mail ' + i + ' is required.'); } Link to comment Share on other sites More sharing options...
vchris Posted December 15, 2006 Author Share Posted December 15, 2006 Perfect! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now