html angular+jquery:判断密码并改变标签样式+新增提示内容
来源:互联网 发布:php手游平台源码 编辑:程序博客网 时间:2024/06/04 20:02
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
#ts {
width: 148px;
}
</style>
<script type="text/javascript" src="js/angular.js"></script>
<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
<script>
flag = false;
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
//只有输入框样式变化
$scope.sel1 = function() {
$scope.sub = function() {
if($scope.text1 == $scope.text2) {
alert("提交成功");
$(function() {
$("input").css("border-color", "black");
});
} else {
$(function() {
$("input").css("border-color", "red");
});
}
}
}
//显示错误提示
$scope.sel2 = function() {
$scope.sub = function() {
if($scope.text1 == $scope.text2 && $scope.text1.length >= 6 && $scope.text2.length >= 6) {
alert("提交成功");
$(function() {
$("input").css("border-color", "black");
$("#ts").html("");
});
} else {
$(function() {
$("input").css("border-color", "red");
if($scope.text1.length < 6 && $scope.text2.length < 6 && $scope.text1 != $scope.text2) {
$("#ts").css("background-color", "pink");
$("#ts").html("<li>密码长度不能小于6个字符!</li><li>密码不能为空!</li><li>两次密码输入不一致!</li>");
} else if($scope.text1 != $scope.text2) {
$("#ts").css("background-color", "pink");
$("#ts").html("<li>两次密码输入不一致</li>");
} else if($scope.text1.length < 6 && $scope.text2.length < 6) {
$("#ts").css("background-color", "pink");
$("#ts").html("<li>密码长度不能小于6个字符!</li>");
}
});
}
}
}
//点击提交才显示错误提示
$scope.sel3 = function() {
$scope.sub = function() {
if($scope.text1 == $scope.text2 && $scope.text1.length >= 6 && $scope.text2.length >= 6) {
alert("提交成功");
$(function() {
$("input").css("border-color", "black");
$("#ts").html("");
});
} else {
$(function() {
$("input").css("border-color", "red");
if($scope.text1.length < 6 && $scope.text2.length < 6 && $scope.text1 != $scope.text2) {
$("#ts").css("background-color", "pink");
$("#ts").html("<li>密码长度不能小于6个字符!</li><li>两次密码输入不一致!</li>");
} else if($scope.text1 != $scope.text2) {
$("#ts").css("background-color", "pink");
$("#ts").html("<li>两次密码输入不一致</li>");
} else if($scope.text1.length < 6 && $scope.text2.length < 6) {
$("#ts").css("background-color", "pink");
$("#ts").html("<li>密码长度不能小于6个字符!</li>");
}
});
}
}
}
});
</script>
</head>
<body ng-app="myApp" ng-controller="myCtrl">
<div style="margin-left: 10%;">
<p style="margin-left: 2.5%;">密码:<input type="password" placeholder="6-20个字符" ng-model="text1" /></p>
<p>重复密码:<input type="password" placeholder="6-20个字符" ng-model="text2" /></p>
<p id="ts" style="margin-left: 5.5%;"></p>
<button ng-click="sub()" style="margin-left: 5.5%;">提交</button>
</div>
显示方式:<br />
<select>
<option selected="selected">--请选择--</option>
<option ng-click="sel1()">只有输入框样式变化</option>
<option ng-click="sel2()">显示错误提示</option>
<option ng-click="sel3()">点击提交才显示错误提示</option>
</select>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
#ts {
width: 148px;
}
</style>
<script type="text/javascript" src="js/angular.js"></script>
<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
<script>
flag = false;
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
//只有输入框样式变化
$scope.sel1 = function() {
$scope.sub = function() {
if($scope.text1 == $scope.text2) {
alert("提交成功");
$(function() {
$("input").css("border-color", "black");
});
} else {
$(function() {
$("input").css("border-color", "red");
});
}
}
}
//显示错误提示
$scope.sel2 = function() {
$scope.sub = function() {
if($scope.text1 == $scope.text2 && $scope.text1.length >= 6 && $scope.text2.length >= 6) {
alert("提交成功");
$(function() {
$("input").css("border-color", "black");
$("#ts").html("");
});
} else {
$(function() {
$("input").css("border-color", "red");
if($scope.text1.length < 6 && $scope.text2.length < 6 && $scope.text1 != $scope.text2) {
$("#ts").css("background-color", "pink");
$("#ts").html("<li>密码长度不能小于6个字符!</li><li>密码不能为空!</li><li>两次密码输入不一致!</li>");
} else if($scope.text1 != $scope.text2) {
$("#ts").css("background-color", "pink");
$("#ts").html("<li>两次密码输入不一致</li>");
} else if($scope.text1.length < 6 && $scope.text2.length < 6) {
$("#ts").css("background-color", "pink");
$("#ts").html("<li>密码长度不能小于6个字符!</li>");
}
});
}
}
}
//点击提交才显示错误提示
$scope.sel3 = function() {
$scope.sub = function() {
if($scope.text1 == $scope.text2 && $scope.text1.length >= 6 && $scope.text2.length >= 6) {
alert("提交成功");
$(function() {
$("input").css("border-color", "black");
$("#ts").html("");
});
} else {
$(function() {
$("input").css("border-color", "red");
if($scope.text1.length < 6 && $scope.text2.length < 6 && $scope.text1 != $scope.text2) {
$("#ts").css("background-color", "pink");
$("#ts").html("<li>密码长度不能小于6个字符!</li><li>两次密码输入不一致!</li>");
} else if($scope.text1 != $scope.text2) {
$("#ts").css("background-color", "pink");
$("#ts").html("<li>两次密码输入不一致</li>");
} else if($scope.text1.length < 6 && $scope.text2.length < 6) {
$("#ts").css("background-color", "pink");
$("#ts").html("<li>密码长度不能小于6个字符!</li>");
}
});
}
}
}
});
</script>
</head>
<body ng-app="myApp" ng-controller="myCtrl">
<div style="margin-left: 10%;">
<p style="margin-left: 2.5%;">密码:<input type="password" placeholder="6-20个字符" ng-model="text1" /></p>
<p>重复密码:<input type="password" placeholder="6-20个字符" ng-model="text2" /></p>
<p id="ts" style="margin-left: 5.5%;"></p>
<button ng-click="sub()" style="margin-left: 5.5%;">提交</button>
</div>
显示方式:<br />
<select>
<option selected="selected">--请选择--</option>
<option ng-click="sel1()">只有输入框样式变化</option>
<option ng-click="sel2()">显示错误提示</option>
<option ng-click="sel3()">点击提交才显示错误提示</option>
</select>
</body>
</html>
阅读全文
0 0
- html angular+jquery:判断密码并改变标签样式+新增提示内容
- html angular+route:模糊查询+下拉排序+新增内容+判断是否重复+输入敏感字提示
- HTML angular定时改变指定文本内容
- HTML angular追加内容,并进行判断原先是否存在和是否存在敏感字符
- 改变 HTML标签样式 和 attribute 改变 HTML 属性
- js改变/获取html标签样式
- jquery如何改变html标签的样式(两种实现方法)
- jquery如何改变html标签的样式(两种实现方法)
- Jquery真的不难~第三回 如何改变HTML标签的样式
- 通过angular.element,转变成jquery对象,改变样式!
- JavaScript和jQuery改变标签内容
- jquery html改变div当中的内容
- jQuery6(获取元素练习,改变标签样式及内容)
- Angular 表单判断密码
- angular简单密码判断
- jquery取出html标签中的内容
- JavaScript-对事件作出反应\改变 HTML 内容\改变 HTML 样式\写入HTML输出
- iOS 直接改变.html后缀的链接所对应的html页面样式,并获取html的标题,图片地址,id,内容
- 查看日志常用命令
- solr中 Could not connect to ZooKeeper
- Adb Push apk简单命令
- junit基础
- CodeForces
- html angular+jquery:判断密码并改变标签样式+新增提示内容
- OMP 正交匹配追踪
- 算术赋值运算符与自增自减运算符
- 给定一个m×n矩阵,如果一个元素为0,则将其整行和列的值设置为0.
- ASM正常冗余下模拟磁盘故障的恢复
- JavaScript 的 this 指向问题深度解析
- bzoj 1087: [SCOI2005]互不侵犯King 状压dp
- C++深入了解虚函数
- centos 编译安装apache