<form action="" name="tem_form">
姓名:<input type="text" ng-model="name" name="name" required><span ng-show="tem_form.name.$error.required">姓名不能为空!</span>
密码:<input type="password" ng-model="password" name="password" required><span ng-show="tem_form.password.$error.required">密码不能为空!</span>
<input type="submit" ng-disabled="tem_form.$invalid" value="提交">
</form>
$pristine 表单或控件内容是否未输入过
$dirty 表单或控件内容是否输入过$valid 表单或控件内容是否已验证通过
$invalid 表单或控件内容是否未验证通过
$error 表单或控件验证时的错误提示信息
本文介绍了一个使用AngularJS实现的表单验证示例,包括必填项验证及实时反馈。通过具体的HTML代码展示了如何利用AngularJS内置指令进行表单元素的绑定与状态检查。
741

被折叠的 条评论
为什么被折叠?



