密码匹配工具提示不工作
Password match tooltip not working
我的问题是,当密码与确认密码不匹配时,我希望在文本字段中出现工具提示
下面是我的工具提示代码。另一个工作,但密码匹配不
function validateContact() {
var valid = true;
$("#container input[required=true], #container textarea[required=true]").each(function(){
$(this).removeClass('invalid');
$(this).attr('title','');
if(!$(this).val()){
$(this).addClass('invalid');
$(this).attr('title','This field is required');
valid = false;
}
if($(this).attr("type")=="email" && !$(this).val().match(/^(['w-'.]+@(['w-]+'.)+['w-]{2,4})?$/)){
$(this).addClass('invalid');
$(this).attr('title','Enter valid email');
valid = false;
}
// for password match
if ($("#Password").val() != $("#ConfirmPassword").val()) {
$(this).addClass('invalid');
$(this).attr('title','Password does not Match');
valid = false;
}
// end of password match
});
return valid;
}
$(function() {
$( document ).tooltip({
position: {my: "left top", at: "right top"},
items: "input[required=true], textarea[required=true]",
content: function() { return $(this).attr( "title" ); }
});
});
这是我的表单代码:
<input type="password" class="form-control" id="Password" tabindex=7 name="Password" placeholder="Password" required="true" >
<input type="password" class="form-control" id="ConfirmPassword" tabindex=8 name="ConfirmPassword" placeholder="Confirm Password" required="true">
我需要一些帮助来解决这个问题
在ValidateContract函数中是否有侦听器?你叫它哪里?
尝试将侦听器直接放在输入上,通过id…更改console.log为工具提示显示/message
$(document).on('keyup', '#ConfirmPassword', function(){
if ($("#Password").val() == $(this).val())
console.log("pass are equal");
else
console.log("pass are not equal D:")
});
相关文章:
- 谷歌散点图-{role:'style'}{role:#39;工具提示'}不能以JSON形式工作
- 关闭Body Click事件的工具提示-工作不正常
- 如何使工具提示从函数本身之外的元素工作
- 多行工具提示无法以编程方式工作
- 如果文本在高图表中较多,则工具提示无法正常工作
- 筛选器操作后,工具提示停止工作
- ExtJS 4.2.1 - 选项卡面板中的网格 - 工具提示停止工作
- 悬停和焦点上的响应式 jQuery 工具提示无法正常工作
- 只要单击页面上的任何内容,引导工具提示就会停止工作
- 如何使工具提示在 HTML 表单中工作
- 如何获取工具提示以在现有 JS 函数中工作
- 引导工具提示不't在与第一个数据表不同的页面中工作
- 类选择器不'不能在通过AJAX加载的工具提示内容中工作
- <br>不在工具提示的标题标记中工作
- 为什么这个工具提示没有'不在IE工作吗?错误:应为对象
- 引导工具提示与角不工作
- 启动工具提示在任何其他事件运行后停止工作
- Jquery工具提示不能在文本/模板上工作
- 工具提示器突然不工作了
- 工具提示不能在ie中工作