Hello. A little while back, forum member MrNobody helped me create this Javascript:
The script works great, except for one small issue. When the form focuses on the required element, it works from the bottom up. That is, it will focus on the bottom form element and work its way up, rather than work its way down. I would like it to work its way down instead of up. Is there anyway to adjust this behavior? Thanks.Code:function validate() { var sections=['terrier', 'sporting', 'mixed', 'poodle', 'salon_free', 'wc', 'creative']; var error='Please Enter: \n'; for(var s=0; s<sections.length; s++) { var group=document.getElementById(sections[s]).getElementsByTagName('input'); var check=false; for(var i=0; i<group.length; i++) { if(group[i].type=='checkbox' && group[i].checked) { check=true; } if(group[i].type=='text' && check && group[i].value=='') { error+=group[i].id+'\n'; group[i].style.background="#FFFF99"; } } group=document.getElementById(sections[s]).getElementsByTagName('select'); for(i=0; i<group.length; i++) { if(check && group[i].selectedIndex < 1) { error+=group[i].id+'\n'; group[i].style.background="#FFFF99"; group[i].focus(); } } } if(error!='Please Enter: \n') { alert(error); } }


Reply With Quote
Bookmarks