Posted By

krisdb on 04/13/07


Tagged

javascript


Versions (?)

firstFieldFocus()


 / Published in: JavaScript
 

  1. function firstFieldFocus(iStart) {
  2. var x,y,i;
  3.  
  4. x = document.getElementsByTagName('input');
  5.  
  6. for (i=iStart; i < x.length; i++) {
  7. y = document.getElementsByTagName('input')[i];
  8. if (y.type == 'text' && y.value == '') {
  9. y.focus();
  10. return;
  11. }
  12. }
  13.  
  14. x = document.getElementsByTagName('textarea')[0];
  15.  
  16. if (x == null) {
  17. return;
  18. }
  19. else {
  20. x.focus();
  21. }
  22. }
  23.  
  24. <script type="text/javascript">firstFieldFocus(0);</script>

Report this snippet  

You need to login to post a comment.