我在停止表单提交事件时遇到问题
i am getting issue in stopping form submission event
伙计们,我在停止表单提交时发现了问题。我有两个用户名和密码字段,如果用户名和密码相同,我想显示警报并停止表单提交。这是我的代码
<form name="myform"ng-submit="checked()" action="change_credintls" method="post" enctype="multipart/form-data">
<input type="text"ng-model="username"name="username"class="form-control"maxlength="20" placeholder="ENTER NEW USERNAME"Required >
<input type="text"name="password"ng-model="pass"class="form-control"maxlength="20" placeholder="ENTER NEW PASSWORD"Required >
<input style="border-radius:0px;"type="submit" CLASS="btn btn-primary btn-sm"value="CHANGE CREDIANTLS">
</form>
这是我的角度代码
<script>
var app= angular.module('myapp',[]);
app.controller('mycntrl',function ($scope){
$scope.checked= function(myform)
{
if($scope.username == $scope.pass)
{
alert("Your user name and password can not be same");
return false;
}
}
});
</script>
警报正在工作,但我无法停止表单提交
试试这个。
.HTML
<form name="myform"ng-submit="checked($event)" action="change_credintls" method="post" enctype="multipart/form-data">
<input type="text"ng-model="username"name="username"class="form-control"maxlength="20" placeholder="ENTER NEW USERNAME"Required >
<input type="text"name="password"ng-model="pass"class="form-control"maxlength="20" placeholder="ENTER NEW PASSWORD"Required >
<input style="border-radius:0px;"type="submit" CLASS="btn btn-primary btn-sm"value="CHANGE CREDIANTLS">
安古勒
<script>
var app= angular.module('myapp',[]);
app.controller('mycntrl',function ($scope){
$scope.checked= function($event,myform)
{
if($scope.username == $scope.pass)
{
//alert("Your user name and password can not be same");
$event.preventDefault()
}
}
});
它应该适合你。
相关文章:
- 将PHP变量传递给jQuery时遇到问题
- 将jQuery转换为用户脚本的普通Javascript时遇到问题
- 将子文档推送到父数组时遇到问题
- JQuery FullCalendar在从ajax成功调用rerenderEvents时遇到问题
- 在将javascript附加到我的html中时遇到问题
- 为什么我在以编程方式打开窗口时遇到问题
- 在将缩略图链接到模态时遇到问题
- 使用 ng 模型获取数据时遇到问题
- 是否有其他人在设计Twitter Typeahead时遇到问题'的搜索栏
- 使用jquery进行整数比较时遇到问题
- 使用PhantomJS下载动态web内容时遇到问题
- 设置RequireJS时遇到问题
- 让Javascript在SharePoint 2010上运行时遇到问题
- I'我在react.js中编写for循环时遇到问题
- 通过jQuery获取上传的文件名时遇到问题
- 我在启动我的节点时遇到问题.js IRC 机器人
- Ruby on Rails 4:在 Rails Web 应用程序中添加 Javascript 文件时遇到问题
- 从谷歌地图自定义控件打开离子模态时遇到问题
- 在使用 YAML 和 Google App Engine 时遇到问题
- 在 Chrome 扩展程序中将鼠标悬停在广告上使用时遇到问题