zoukankan      html  css  js  c++  java
  • 夺命雷公狗—angularjs—2—模拟表单验证

    这里我们就来借助妹子ui来搭建下模版,废话不多说,代码如下图所示:

    <!doctype html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <link rel="stylesheet" href="css/amazeui.min.css">
        <script src="js/jq2.js"></script>
        <script src="js/amazeui.min.js"></script>
    
    </head>
    <body ng-app="myapp">
        <div style=" 250px; margin: 0 auto" ng-controller="forms">
            <div class="am-alert {{color}} " data-am-alert ng-show="errorMsg.length > 0">
                <button type="button" class="am-close">&times;</button>
                <p>{{errorMsg}}</p>
            </div>
            <h1>登录表单</h1>
            <div class="am-input-group">
                <span class="am-input-group-label"><i class="am-icon-user am-icon-fw"></i></span>
                <input type="text" class="am-form-field" placeholder="Username" ng-model="user.name" >
            </div>
    
            <div class="am-input-group">
                <span class="am-input-group-label"><i class="am-icon-lock am-icon-fw"></i></span>
                <input type="password" class="am-form-field" placeholder="Password" ng-model="user.pass" >
            </div>
    
            <div class="am-g" style="margin-top: 15px">
                <div class="am-u-sm-6 am-text-center">
                    <button type="button" class="am-btn am-btn-success" ng-click="login()" >登录</button>
                </div>
                <div class="am-u-sm-6 am-text-center">
                    <button type="button" class="am-btn am-btn-default">取消</button>
                </div>
            </div>
        </div>
    </body>
    <script src="js/angular.min.js"></script>
    <script>
        var module = angular.module("myapp",[]);
            module.controller('forms',function($scope){
                $scope.user = {name:'',pass:''};
                $scope.errorMsg = '';
                $scope.login = function(){
                    console.log($scope.user.name);
                    console.log($scope.user.pass);
                    if($scope.user.name == 'admin' && $scope.user.pass == 'admin888'){
                        $scope.errorMsg = 'YES~~~~';
                        $scope.color = "am-alert-success";
                    }else{
                        $scope.errorMsg = 'NO~~~~~';
                        $scope.color = "am-alert-danger";
                    }
            }
        })
    
    </script>
    </html>

    效果如下图所示:

  • 相关阅读:
    [翻译]NUnitString && Collection && File && Directory Assert (七)
    c++删除指定字符串之间的内容(比正则表达式快几十倍)[转]
    C++ 使用正则表达式分割字符串
    c++正则查找
    PHP的XSS攻击过滤函数
    Boost之正则表达式_[转]
    C++中的类所占内存空间总结[转]
    make_shared() shared_prt()详解区别
    C++ STRING 和WSTRING 之间的互相转换函数 和字符串替换
    LConfig:利用Lua脚本做程序的配置文件 [转]
  • 原文地址:https://www.cnblogs.com/leigood/p/5780287.html
Copyright © 2011-2022 走看看