html进行测试

    技术2022-08-07  2

    <HTML>        <HEAD>                <script language="javascript" src="aaaaa.js"></script>        </HEAD>        <SCRIPT LANGUAGE="JavaScript"><!--/** * 表单验证的示例js方法. */function check(){        if(checkIfEmpty('a','非空校验')                &&checkIsMail('b','邮箱校验')                &&checkIsNum('c','数字校验')                &&checkIsValid('d','合法性校验')                &&compareTwoDate('e','f','小日期与大日期关系错误!')                &&checkLength('g',5,'长度校验')                &&checkChooseSelect('h','下拉菜单非空','-1')                &&compareTwoNum('k','l','大小数目关系不正确!')){                alert('校验通过!');                return true;                }else{                return false;        }}

    /** * 取下拉菜单的值和文本的示例js方法. */function getSelect(){        var sss = $('h');        alert('下拉菜单选择的文本是:'+getSelectText(sss)+'/n'                        +'下拉菜单选择的值是:'+getSelectValue(sss));}

    /** * 根据键值字符串设置下拉菜单的显示内容. */function setSelect(){        var sss = $('i').value;        setSelectContent($('h'),sss);}

    /** * 返回多选框数组选择状态的id的字符串,结果以逗号隔开. */function getMulti(){         alert('多选选择的id是:'+getCheckedIds(document.getElementsByName('j')));}//--></SCRIPT>        <BODY>                <table>                        <tr>                                <td>                                        非空:                                        <input id='a'>                                </td>                                <td>                                        checkIfEmpty('a','非空校验')                                </td>                        </tr>                        <tr>                                <td>                                        邮箱:                                        <input id='b' value='323232@2323.com'>                                </td>                                <td>                                        checkIsMail('b','邮箱校验')                                </td>                        </tr>                        <tr>                                <td>                                        数字:                                        <input id='c' value='aaaa'>                                </td>                                <td>                                        checkIsNum('c','数字校验')                                </td>                        </tr>                        <tr>                                <td>                                        合法字符:                                        <input id='d' value='@$@$#$#!%%#'>                                </td>                                <td>                                        checkIsValid('d','合法性校验')                                </td>                        </tr>                        <tr>                                <td>                                        小的日期:                                        <input id='e' value='2010-1-1'>                                        大的日期:                                        <input id='f' value='2011-1-1'>                                </td>                                <td>                                        compareTwoDate('e','f','小日期与大日期关系错误!')                                </td>                        </tr>                        <tr>                                <td>                                        小的数:                                        <input id='k' value='12.3'>                                        大的数:                                        <input id='l' value='4564'>                                </td>                                <td>                                        compareTwoNum('k','l','大小数目关系不正确!')                                </td>                        </tr>                        <tr>                                <td>                                        字符长度校验(<5):                                        <input id='g'>                                </td>                                <td>                                        checkLength('g',5,'长度校验')                                </td>                        </tr>                        <tr>                                <td>                                        下拉菜单非空校验:                                        <select id='h'>                                                <option value='-1'>                                                        请选择                                                </option>                                                <option value='1'>                                                        立项                                                </option>                                                <option value='2'>                                                        可研                                                </option>                                        </select>                                </td>                                <td>                                        checkChooseSelect('h','下拉菜单非空','-1')                                </td>                        </tr>                        <tr>                                <td colspan='2'>                                        <button οnclick='check()'>                                                测试表单校验方法                                        </button>                                </td>                        </tr>                        <tr>                                <td>

                                            <button οnclick='getSelect()'>                                                得到下拉菜单的值                                        </button>                                </td>                                <td>                                        getSelectText(sss)和getSelectValue(sss)                                </td>                        </tr>                        <tr>                                <td>                                        输入下拉菜单的键值字符串(如右所示)                                        <input id='i' value='1,男;2,女;3,未知'>                                        <button οnclick='setSelect()'>                                                设置下拉菜单的值                                        </button>                                </td>                                <td>                                        setSelectContent($('h'),sss)                                </td>                        </tr>                        <tr>                                <td>

                                            <input type='checkbox' name='j' value='aaa1'>                                        <input type='checkbox' name='j' value='aaa2'>                                        <input type='checkbox' name='j' value='aaa3'>                                        <input type='checkbox' name='j' value='aaa4'>                                        <button οnclick='getMulti()'>                                                得到多选选择的id                                        </button>                                </td>                                <td>                                        getCheckedIds(document.getElementsByName('j'))                                </td>                        </tr>                </table>        </BODY></HTML>

    最新回复(0)