• 夺命雷公狗—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>

    效果如下图所示:

  • 相关阅读:
    浏览器 cookie
    c# 委托
    并不对劲的loj3106:p5339:[TJOI2019]唱、跳、rap 和篮球
    并不对劲的loj3095:p5329:[SNOI2019]字符串
    并不对劲的CF1365D&E&F: Solve The Maximum Subsequence Again
    并不对劲的loj3123:p5404[CTS2019]重复
    并不对劲的loj3046:p5327:[ZJOI2019]语言
    并不对劲的loj3115:p5362:[SDOI2019]连续子序列
    并不对劲的loj3113:p5360:[SDOI2019]热闹的聚会与尴尬的聚会
    并不对劲的bzoj2521:p5039:[SHOI2010]最小生成树
  • 原文地址:https://www.cnblogs.com/leigood/p/5780287.html
Copyright © 2020-2023  润新知