• FormUtil


    var FormUtil = new Object;

    FormUtil.focusOnFirst 
    = function () {
        
    if (document.forms.length > 0) {
            
    for (var i=0; i < document.forms[0].elements.length; i++) {
                
    var oField = document.forms[0].elements[i];
                
    if (oField.type != "hidden") {
                    oField.focus();
                    
    return;
                }
            }
        }
    };

    FormUtil.setTextboxes 
    = function() {
        
    var colInputs = document.getElementsByTagName("input");
        
    var colTextAreas = document.getElementsByTagName("textarea");
            
        
    for (var i=0; i < colInputs.length; i++){
            
    if (colInputs[i].type == "text" || colInputs [i].type == "password") {
                colInputs[i].onfocus 
    = function () { this.select(); };
            }
        }
            
        
    for (var i=0; i < colTextAreas.length; i++){
            colTextAreas[i].onfocus 
    = function () { this.select(); };
        }
    };

    FormUtil.tabForward 
    = function(oTextbox) {

        
    var oForm = oTextbox.form;

        
    //make sure the textbox is not the last field in the form
        if (oForm.elements[oForm.elements.length-1!= oTextbox 
            
    && oTextbox.value.length == oTextbox.maxLength) {
                   
            
    for (var i=0; i < oForm.elements.length; i++) {
                
    if (oForm.elements[i] == oTextbox) {
                     
    for(var j=i+1; j < oForm.elements.length; j++) {
                         
    if (oForm.elements[j].type != "hidden") {
                             oForm.elements[j].focus();
                             
    return;
                         }
                     }
                     
    return;
                }
            }
        }
    };



  • 相关阅读:
    博客备份小工具3
    博客转发小工具1
    04-属性选择器
    05-伪类选择器
    03-高级选择器
    02-css的选择器
    01-css的引入方式
    函数进阶-(命名空间、作用域、函数嵌套、作用域链、函数名本质、闭包)
    函数基础-(引子、定义函数、调用函数、函数返回值、函数参数)
    Python之路【第08章】:Python函数
  • 原文地址:https://www.cnblogs.com/jackhuclan/p/1150099.html
Copyright © 2020-2023  润新知