检查密码是否包含用户名jquery [英] check if password contains username jquery
本文介绍了检查密码是否包含用户名jquery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我拥有的代码,它正在执行某些操作,而不是我需要的.有帮助吗?
Here is the code i have and its doing something, just not what i need it to. Any help?
reee = /$('#username').val()/;
if(reee.test($('#password').val()))
我什至尝试了
reee = $('#username').val();
if(reee.test($('#password').val()))
如果我不包括/(我对jQuery来说是新的,所以我的功能在此if语句处停止,所以我不是100%确定/做,但是我知道我是否给出了像/0-9/
这样的范围,它将查看是否数字存在.
my function stops at this if statement if i dont include the / (im kind of new to jquery so im not 100% sure that the / do but i know if i gave a range like /0-9/
it will see if a number is present.
推荐答案
reee = new RegExp($('#username').val(),g);
if(reee.test($('#password').val()))
尝试...
或check if password contains username
为什么不使用indexOf
?
var username = "reigel";
var password = "reigelgallarde"
alert(password.indexOf(username) != -1); // alerts true
indexOf 返回该字符串在另一个字符串中的位置细绳.如果找不到,它将返回-1.
indexOf returns the position of the string in the other string. If not found, it will return -1.
这篇关于检查密码是否包含用户名jquery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文