zoukankan      html  css  js  c++  java
  • 20、Semantic-UI之数据验证

    20.1 实现数据验证

      在很多前端框架中都提供了数据验证的操作,比如jQuery的验证框架等,但是jQuery的验证框架js文件太多;在使用Semantic-UI框架的时候只需要导入semantic.js文件就可以实现数据验证,当然必须导入jQuery才可以。

    示例:定义表单

    <div class="ui container">
        <div class="ui grid">
            <div class="four wide column">
                <form action="" method="post" class="ui form">
                    <div class="field">
                        <i class="user icon"></i>
                        <label for="name">姓名</label>
                        <input type="text" name="name" id="name" placeholder="请输入姓名...">
                    </div>
                    <div class="field">
                        <i class="id badge icon"></i>
                        <label for="name">年龄</label>
                        <input type="text" name="age" id="age" placeholder="请输入年龄...">
                    </div>
                    <div class="field">
                        <i class="compass icon"></i>
                        <label for="name">密码</label>
                        <input type="text" name="passwd" id="passwd" placeholder="请输入密码...">
                    </div>
                    <button class="ui green button">注册</button>
                </form>
            </div>
        </div>
    </div>
    

    示例:定义验证规则

    <script>
        $(function () {
            $(".ui.form").form({
                fields:{
                    name:{
                        indentfier:"name",
                        rules:[{
                            type:"empty",
                        }]
                    },
                    age:{
                        indentfier:"age",
                        rules:[{
                            type:"integer",
                        }]
                    },
                    passwd:{
                        indentfier:"age",
                        rules:[{
                            type:"empty",
                        }]
                    }
                }
            })
        })
    </script>
    

    上述验证规则只适合在Semantic-UI中使用。

  • 相关阅读:
    5. Longest Palindromic Substring
    4. Median of Two Sorted Arrays(topK-logk)
    apache开源项目--Derby
    apache开源项目--Apache Drill
    apache开源项目-- OODT
    apache开源项目--Mavibot
    apache开源项目--ApacheDS
    apache开源项目--TIKA
    apache开源项目--Mahout
    apache开源项目--Jackrabbit
  • 原文地址:https://www.cnblogs.com/jie-fang/p/10279588.html
Copyright © 2011-2022 走看看