这里我们就来借助妹子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="width: 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>

效果如下图所示:

夺命雷公狗—angularjs—2—模拟表单验证的更多相关文章

  1. AngularJS中的表单验证

    AngularJS中的表单验证 AngularJS自带了很多验证,什么必填,最大长度,最小长度...,这里记录几个有用的正则式验证 1.使用angularjs的表单验证 正则式验证 只需要配置一个正则 ...

  2. MVC身份验证.MVC过滤器.MVC6关键字Task,Async.前端模拟表单验证,提交.自定义匿名集合.Edge导出到Excel.BootstrapTree树状菜单的全选和反选.bootstrap可搜索可多选可全选下拉框

    1.MVC身份验证. 有两种方式.一个是传统的所有控制器继承自定义Control,然后再里面用MVC的过滤器拦截.所以每次网站的后台被访问时.就会先走入拦截器.进行前端和后端的验证 一个是利用(MVC ...

  3. 夺命雷公狗—angularjs—6—单条数据的遍历

    我们在实际的工作中常常会处理到一些数据的遍历,这些数据都是后端传到前端的,有些公司会让前端帮忙处理一点遍历的工作,废话不多说,直接上代: <!doctype html> <html ...

  4. angularJS中的表单验证(包括自定义验证)

    表单验证是angularJS一项重要的功能,能保证我们的web应用不会被恶意或错误的输入破坏.Angular表单验证提供了很多表单验证指令,并且能将html5表单验证功能同他自己的验证指令结合起来使用 ...

  5. AngularJS入门基础——表单验证

    <form name="form" novalidata>   <label name="email">your email</l ...

  6. 夺命雷公狗—angularjs—3—表单验证的高级用法

    其实我们的angularjs都是是块状代码,其实是可以在实际开发中保存下来以后就可以达到重复利用的目的了.. 废话不多说,直接上代码: <!doctype html> <html l ...

  7. 夺命雷公狗—angularjs—13—post参数的接收发送

    我们强悍的angularjs为我们不仅仅提供了他的get接收方式,而且也有post的接收方式,我们现在做一个模拟接收后端传递过来的json的数据: <?php $arr = ['user'=&g ...

  8. 夺命雷公狗—angularjs—25—angular内置的方法(高级)

    查看版本信息 angular.version console.log(angular.version); 判断是否相等 angular.equals() var str1 = ''; var str2 ...

  9. 夺命雷公狗—angularjs—24—extend继承对象

    我们的angularjs中也是给我们留下了方法来做继承的,那么他就是传授中的extend... 不过要如下所示,第二个参数是继承到第一个对象里面的... <!DOCTYPE html> & ...

随机推荐

  1. 转: PE rva to raw 虚拟偏移地址和文件物理偏移地址

    +---------+---------+---------+---------+---------+---------+| 段名称 虚拟地址 虚拟大小 物理地址 物理大小 标志 |+-------- ...

  2. 使用多种客户端消费WCF RestFul服务(一)——服务端

    RestFul风格的WCF既然作为跨平台.跨语言.跨技术的一种方式出现,并且在ASP.NET API流行起来之前还是架构的首选技术之一,那么我们就来简要的介绍一下WCF在各个平台客户端的操作. 开发工 ...

  3. 三星的中低端机使用AsyncTask的问题

    三星的中低端机上在子线程中使用AsyncTask会报 01-15 23:46:20.165: W/dalvikvm(7259): Exception Ljava/lang/RuntimeExcepti ...

  4. IAdaptable和IAdaptableFactory(转)

    先记在这里,回头研究下. 原文:http://blog.csdn.net/mini_snow/article/details/3877379 1. 简介和简单的实现 IAdapteable实际上在Ec ...

  5. HttpPost发送Json

    1.public static JSONObject post(String url,JSONObject json){ 2. HttpClient client = new DefaultHttpC ...

  6. 用httpPost对JSON发送和接收

    HTTPPost发送JSON: private static final String APPLICATION_JSON = "application/json"; private ...

  7. detailsview 样式小问题

    detailsview不显示表头,设置HeaderText=""就可以,不知道为什么,如果有值,其他方式都没有调好! 内网格显示为0,Gridlines="None&qu ...

  8. HTML知识点总结以及典型例子讲解

    一.HTML文本格式化标签(这些标签都不换行) eg: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN&qu ...

  9. iOS 增加UIButton按钮的可点击区域

    在很多时候,按钮可能看起来那么大,但是在它周围进行点击时,都能够触发事件,是因为它的可点击区域比我们看到的button要大. 在使用AutoLayout的时候,我们处理的是按钮的image属性,所以这 ...

  10. android apk简单反编译

    1. 查看或者提取资源文件:     使用谷歌官方工具apktool,命令行如下: apktool d xxx.apk xxx_decode d代表反编译,xxx.apk为你要反编译的apk,xxx_ ...