扫码关注官方订阅号
form表单中“用户名是否已存在?”在angularJ中,如何发起ajax请求,查询并判断用户名是否已存在?
blur 的时候 发一个 ajax 请求判断下就好了
用户名: <input type="text" name="user" ng-model="user" required> <span style="color:red" ng-show="myForm.user.$dirty && myForm.user.$invalid"> <span ng-show="myForm.user.$error.required">用户名是必须的。</span> </span>
<input type="text" ng-model="user" blur="checkName()"> $scope.checkName = function(){ //用$scope.user去请求验证的service,根据结果显示是否存在 }
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
blur 的时候 发一个 ajax 请求判断下就好了
用户名:
<input type="text" name="user" ng-model="user" required>
<span style="color:red" ng-show="myForm.user.$dirty && myForm.user.$invalid">
<span ng-show="myForm.user.$error.required">用户名是必须的。</span>
</span>
类似这样