zoukankan      html  css  js  c++  java
  • 密码校验

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
    .red{
    border: 1px solid red;
    }
    </style>
    <script src="../angular-1.5.5/angular.js"></script>
    <script>
    var myapp=angular.module("myapp",[]);
    myapp.controller("myCtrl",function($scope){
    $scope.check=false;
    $scope.pas1="";
    $scope.pas2="";
    $scope.show=false;
    $scope.opt="只有输入框样式变化";

    $scope.fun=function(){
    console.log($scope.opt);
    if($scope.opt=="只有输入框样式变化"){
    $scope.$watch("pas2",function(value){
    if(value!=""){
    if(value==$scope.pas1){
    $scope.check=false;
    }else{
    $scope.check=true;
    }
    }
    });
    }else if($scope.opt=="显示错误提示"){
    $scope.$watch("pas2",function(value){
    if(value!=""){
    if(value==$scope.pas1){
    $scope.check=false;
    $scope.show=false;
    }else{
    $scope.check=true;
    $scope.show=true;
    }
    }
    });
    }else if($scope.opt=="点击提交"){
    $scope.tj=function(){
    if($scope.pas2!=""){
    if($scope.pas2==$scope.pas1){
    $scope.check=false;
    $scope.show=false;
    }else{
    $scope.check=true;
    $scope.show=true;
    }
    }
    }
    }
    }
    })
    </script>

    </head>
    <body ng-app="myapp" ng-controller="myCtrl">
    <input type="password" ng-model="pas1" ng-class="{red:check}"><br>
    <input type="password" ng-model="pas2" ng-class="{red:check}"><br/>
    <ul ng-show="show">
    <li>密码长度不小于6</li>
    <li>密码不能为空</li>
    <li>两次密码输入不一致</li>
    </ul>
    <button ng-click="tj()">按钮</button><br/>
    <select ng-model="opt" ng-change="fun()">
    <option>只有输入框样式变化</option>
    <option>显示错误提示</option>
    <option>提交</option>
    </select>
    </body>
    </html>
  • 相关阅读:
    黑马程序员——指针的应用
    黑马程序员——C语言基础常量、运算符、函数
    黑马程序员——数组
    黑马程序员——循环结构for,while,do..while
    webView去掉右侧导航条
    使用Eclipse构建Maven的SpringMVC项目
    win7 自动登录
    eclipse 自动提示
    apache+php+mysql 环境配置
    KMP子串查找算法
  • 原文地址:https://www.cnblogs.com/wsq110/p/7722288.html
Copyright © 2011-2022 走看看