課程
/前端開發(fā)
/Angular
/AngularJS表單驗證
為什么不能提供一下代碼呢。自己不想寫 浪費時間 如果老師提供的話 調試一下就掌握了。
2017-09-23
源自:AngularJS表單驗證 2-3
正在回答
/**
?* Create by tut on 2018/11/11.
?*/
angular.module("myApp",[])
.controller("MainController", function($scope){
$scope.submitForm = function(){
console.log('表單提交成功!');
}
})
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" type="text/css" href="lib/bootstrap-3.3.7.min.css">
<!--<link rel="stylesheet" type="text/css" href="css/index.css">
-->
<style type="text/css">
.red{
background-color: #a30;
.error{
border:1px solid #a10;
</style>
</head>
<body ng-app="myApp" ng-controller="MainController">
<form name="signUpForm" ng-submit="submitForm()">
<div class="form-group">
<label>風鈴:</label>
<input name="username"
ng-model="username"
class="form-control"
ng-class="{ 'error':signUpForm.username.$invalid && signUpForm.username.$touched }"
ng-minlength="6" required>
</div>
</form>
<script src="lib/angular-1.7.5.min.js"></script>
<script src="js/index.js"></script>
</body>
</html>
自己動手,豐衣足食
舉報
一看就明白的AngularJS表單驗證
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2018-11-12
/**
?* Create by tut on 2018/11/11.
?*/
angular.module("myApp",[])
.controller("MainController", function($scope){
$scope.submitForm = function(){
console.log('表單提交成功!');
}
})
2018-11-12
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" type="text/css" href="lib/bootstrap-3.3.7.min.css">
<!--<link rel="stylesheet" type="text/css" href="css/index.css">
-->
<style type="text/css">
.red{
background-color: #a30;
}
.error{
border:1px solid #a10;
}
</style>
</head>
<body ng-app="myApp" ng-controller="MainController">
<form name="signUpForm" ng-submit="submitForm()">
<div class="form-group">
<label>風鈴:</label>
<input name="username"
ng-model="username"
class="form-control"
ng-class="{ 'error':signUpForm.username.$invalid && signUpForm.username.$touched }"
ng-minlength="6" required>
</div>
</form>
<script src="lib/angular-1.7.5.min.js"></script>
<script src="js/index.js"></script>
</body>
</html>
2017-10-10
自己動手,豐衣足食