jQuery mobile ——制作表单

jQuery mobile ——制作表单

jQuery mobile学习

3.请运用jQuery mobile功能,将以下关于问卷调查的表单(Form)页面完成,请注意网页版面的调整,使得手机画面能够工整与美观。请同学完成此网页内容与相应所需的java script。

涉及的知识

  1. jQuery mobile 的使用
  2. 表单 的制作

代码实现

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>3-用jQuery Mobile 写表单</title>

    <link href="jquery.mobile-1.2.0.css" rel="stylesheet" />
    <script src="jquery-1.7.1.min.js"></script>
    <script src="jquery.mobile-1.2.0.js"></script>

    <style type="text/css">
        .label1_stytle {
     
            font-weight: bold;
            display: inline-block;
            width: 100px;
            margin-bottom: 15px;
            margin-left: 15px;
            margin-right:50px;
        }

        .p_background {
     
            background: #a6a2a2;
            font-weight: bold;
            margin-left: 15px;
            margin-right: 15px;
        }

        .label2_sytle {
     
            font-weight: bold;
            display: inline-block;
            margin-bottom: 15px;
            margin-left: 15px;
        }

        .input1_stytle {
     
            background: #c7f3e7;
            margin-bottom: 15px;
            margin-left: 15px;
            margin-right: 15px;
        }


        .div1_content {
     
            border: solid #000000; /*设置边框样式跟颜色*/
            border-width: 1px; /*设置边框宽度*/
            width: 630px; /*设置div宽度*/
            height: 350px; /*设置div高度*/
            margin: 0 auto; /*设置div居中*/
        }

        .div2_content {
     
            border: solid #000000; /*设置边框样式跟颜色*/
            border-width: 1px; /*设置边框宽度*/
            width: 630px; /*设置div宽度*/
            margin-bottom: 15px;
            height: 350px; /*设置div高度*/
            margin: 0 auto; /*设置div居中*/
        }

        .p_stytle {
     
            width: 630px; /*设置div宽度*/
            margin: 0 auto; /*设置div居中*/
            margin-bottom: 15px;
            margin-top: 15px;
        }

        .div3_content {
     
            border: solid #000000; /*设置边框样式跟颜色*/
            border-width: 1px; /*设置边框宽度*/
            width: 630px; /*设置div宽度*/
            margin-bottom: 15px;
            height: 200px; /*设置div高度*/
            margin: 0 auto; /*设置div居中*/
        }
        .div4_content {
     
            border: 0; /*设置边框样式跟颜色*/
            border-width: 1px; /*设置边框宽
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
制作验证Jquery,可以按照以下步骤进行: 1. 引入Jquery库文件和验证插件文件。 2. 编写HTML代码,给需要验证的元素添加相应的属性,如required、pattern等。 3. 编写Jquery代码,在文档加载完成后,使用选择器选中需要验证的元素,并调用验证插件的方法进行验证设置。 4. 在Jquery代码中编写验证规则,如判断元素是否为空、是否符合指定的正则达式等。 5. 编写提示信息,当验证不通过时,提示用户相应的错误信息。 6. 最后,编写提交代码,当验证通过时,可以提交数据到后台进行处理。 下面是一个简验证Jquery的示例代码: ``` <!DOCTYPE html> <html> <head> <title>验证Jquery示例</title> <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> <script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/jquery.validate.min.js"></script> </head> <body> <form id="form"> <label for="username">用户名:</label> <input type="text" id="username" name="username" required> <br> <label for="password">密码:</label> <input type="password" id="password" name="password" required> <br> <label for="email">邮箱:</label> <input type="email" id="email" name="email" required> <br> <button type="submit">提交</button> </form> <script> $(document).ready(function() { $("#form").validate({ rules: { username: { required: true }, password: { required: true }, email: { required: true, email: true } }, messages: { username: { required: "用户名不能为空" }, password: { required: "密码不能为空" }, email: { required: "邮箱不能为空", email: "请输入正确的邮箱格式" } }, submitHandler: function(form) { // 提交代码 } }); }); </script> </body> </html> ``` 在这个示例代码中,使用了Jquery的validate插件来进行验证设置,包括了元素的验证规则和提示信息。当验证通过时,可以在submitHandler函数中编写提交的代码。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值