第一个dojo例子

<%@ page language="java" pageEncoding="UTF-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <title>注册案例</title>
        <style type="text/css">
        @import "scripts/dojo/resources/dojo.css";

        @import "scripts/dijit/themes/tundra/tundra.css";

        .dijitInputFieldFocused {
            border: solid 2px #FFDF00;
        }
        </style>

        <script type="text/javascript" djConfig="parseOnLoad: true"
            src="scripts/dojo/dojo.js"></script>
            
        <script type="text/javascript">
            dojo.require("dijit.form.Button");
            dojo.require("dijit.form.TextBox");
            //日历
            dojo.require("dijit.form.DateTextBox");
            //单选按钮和多选按钮
            dojo.require("dijit.form.CheckBox");
            //下拉列表
            dojo.require("dijit.form.FilteringSelect");
            //数字选项
            dojo.require("dijit.form.NumberSpinner");
            //验证
            dojo.require("dijit.form.ValidationTextBox");
               dojo.require("dojox.validate.regexp");
            //解析器
            dojo.require("dojo.parser");
        </script>
    </head>

    <body class="tundra">
        <form id="registForm" method="post">
            <table>
                <tr>
                    <td>
                        <label for="username">
                            用户名
                        </label>
                    </td>
                    <td>
                        <input dojoType="dijit.form.TextBox" type="text" id="username" name="username"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="password">
                            密码
                        </label>
                    </td>
                    <td>
                        <input dojoType="dijit.form.TextBox" type="password" id="password" name="password"/>
                    </td>
                </tr>
                <!-- 单项选择按钮 -->
                <tr>
                    <td>
                        <label for="sex1">
                            性别
                        </label>
                    </td>
                    <td>
                        <input dojoType="dijit.form.RadioButton" type="radio" name="sex"
                            id="sex1" value="男" checked="checked"/>
                        <label for="sex1">
                            男
                        </label>
                        <input dojoType="dijit.form.RadioButton" type="radio" name="sex"
                            id="sex2" value="女" />
                        <label for="sex2">
                            女
                        </label>
                        <input dojoType="dijit.form.RadioButton" type="radio" name="sex"
                            id="sex3" value="保密" />
                        <label for="sex3">
                            保密
                        </label>
                    </td>
                </tr>
                <!-- 年龄 -->
                <tr>
                    <td>
                        <label for="age">年龄</label>
                    </td>
                    <td>
                        <input dojoType="dijit.form.NumberSpinner"
                            value="18"
                            class="medium"
                            constraints="{max:100,places:0}"
                            name="age"
                            id="age"
                            required="true">
                    </td>
                </tr>
                <!-- 日历 -->
                <tr>
                    <td>
                        <label for="birthday">
                            出生日期
                        </label>
                    </td>
                    <td>
                        <input id="birthday" value="1900-01-01" name="birthday"
                        dojoType="dijit.form.DateTextBox"
                        constraints="{min:'1900-01-01',max:'today',formatLength:'long'}"
                        required="true"
                        trim="true">
                    </td>
                </tr>
                <!-- 多项选择按钮 -->
                <tr>
                    <td>
                        <label for="interest1">
                            兴趣
                        </label>
                    </td>
                    <td>
                        <input type="checkbox" dojoType="dijit.form.CheckBox"
                            name="interest" id="interest1" value="电脑">
                        <label for="interest1">
                            上网
                        </label>
                        <input type="checkbox" dojoType="dijit.form.CheckBox"
                            name="interest" id="interest2" value="游泳">
                        <label for="interest2">
                            游泳
                        </label>
                        <input type="checkbox" dojoType="dijit.form.CheckBox"
                            name="interest" id="interest3" value="网球">
                        <label for="interest3">
                            网球
                        </label>
                        <input type="checkbox" dojoType="dijit.form.CheckBox"
                            name="interest" id="interest4" value="看书">
                        <label for="interest4">
                            看书
                        </label>
                    </td>
                </tr>
                <!-- 下拉列表 -->
                <tr>
                    <td>
                        <label for="nationality">
                            国籍
                        </label>
                    </td>
                    <td>
                        <select dojoType=dijit.form.FilteringSelect name="nationality"
                            id="nationality" hasDownArrow="true">
                            <option value="chinese">chinese</option>
                            <option value="USA">USA</option>
                            <option value="English">English</option>
                        </select>
                    </td>
                </tr>
                <!-- email -->
                <tr>
                    <td>
                        <label>E-mail</label>
                    </td>
                    <td>
                        <input id="email" type="text" name="email" class="long" value="youname@qq.com"
                            dojoType="dijit.form.ValidationTextBox"
                            regExpGen="dojox.regexp.emailAddress"
                            trim="true"
                            required="true"
                            invalidMessage="E-mail地址是非法的。" />
                    </td>
                </tr>
            </table>
        </form>
        <button dojoType="dijit.form.Button">
                        提交
            <script type="dojo/method" event="onClick">
                        function registCallBack(data,params){
                            dojo.byId("showData").innerHTML = data;
                        }
                        function registError(data,params){
                            dojo.byId("showData").innerHTML = '服务器错误';
                        }
                        dojo.xhrPost({
                            url:'./regist.do',
                            load:registCallBack,
                            error:registError,
                            form:'registForm',
                            encoding:'utf-8'
                        });
            </script>
        </button>
        <div id="showData"></div>
    </body>
</html>
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值