vchris 3 Posted December 14, 2006 Report 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? Quote Link to post Share on other sites
pulpfiction 0 Posted December 14, 2006 Report 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.'); } Quote Link to post Share on other sites
vchris 3 Posted December 15, 2006 Author Report Share Posted December 15, 2006 Perfect! Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.