如何使用angularjs实现表单验证
2024-09-25 20:35:13
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<title>angularjs-validate</title>
<script type="text/javascript" src="js/angular.min.js"></script>
</head>
<body>
<form name="form1" id="form1">
账号:<input type="text" name="username" ng-model="username" required>
<span style="color:red" ng-show="form1.username.$dirty && form1.username.$invalid">
<span ng-show="form1.username.$error.required">请输入账号</span>
</span>
<br />
邮箱:<input type="text" name="email" ng-model="email" required>
<span style="color:red" ng-show="form1.email.$dirty && form1.email.$invalid">
<span ng-show="form1.email.$error.required">请输入邮箱</span>
</span> <p>
<input type="submit" ng-disabled="form1.username.$dirty && form1.username.$invalid || form1.email.$dirty && form1.email.$invalid">
</p>
</form>
<script>
var app = angular.module('myApp', []);
</script>
</body>
</html>
最新文章
- node使用xml-writer生成本地XML文件实例
- angular学习笔记(二十八-附2)-$http,$resource中的promise对象
- Redis作为消息队列服务场景应用案例
- 数据库开发基础-SQl Server 变量、运算符、if、while
- SHOW OPEN TABLES – what is in your table cache
- 002..NET MVC实现自己的TempBag
- poi设置excel表格边框、字体等
- AtomicInteger类的理解及使用
- SPFA小总结
- 3D Slicer Hide 3D Cube and Axis Labels Programmatically 使用代码隐藏三维视图中的方框和坐标轴标签
- 560. Subarray Sum Equals K 求和为k的子数组个数
- 524 (Div. 2) Masha and two friends
- 杜教BM
- CSS定位之position详解
- AIX平台安装Oracle11gR2数据库
- Activiti学习之 多实例实现会签功
- 最小生成树问题------------Prim算法(TjuOj_1924_Jungle Roads)
- 03: MySQL基本操作
- fiddler script建议教程
- 安装php扩展redis (windows环境)
热门文章
- apache 占用内存总量与每个apache进程的平均内存占用量计算
- HTML的介绍
- LBP,LBP-TOP的MATLAB公开代码
- 使用Nginx的配置对cc攻击进行简单防御
- Flask实战第38天:前台模型创建
- 【BZOJ 1060】 1060: [ZJOI2007]时态同步 (树形DP)
- Codeforces 555 C. Case of Chocolate
- 实验四实验报告————Android基础开发
- [bzoj1009](HNOI2008)GT考试 (kmp+矩阵快速幂加速递推)
- 你一定喜欢看的 Webpack 2.&#215; 入门实战(转载)