Can some one please guide me how should I troubleshoot one more thing. On the same link i am using JS validation for form → https://codepen.io/hmphry/pen/IFrva from the above code. It is working fine, but it doesn’t work for textarea and selections( <options>XXX</options> ).
Can someone please guide me what step should I take to troubleshoot this?
What’re you trying to do with this set of lines? This code submits the form, but it’s in your false condition.
Also the second line is redundant.
The second problem is this line:
var index = $(this).prevAll().length+1;
That always returns 1 because you’re wrapping things in divs, meaning there are no children directly before it.
The line only works if your form objects are siblings.
The correct line, if you only have a single form on the page, would be
var index = $(this).index('.validate')+1;
(alternatively, get rid of all the +1’s you’ve got laying around and index by 0 like a coder