Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/367.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用JavaScript“;正则表达式;在Asp.Net中_Javascript - Fatal编程技术网

使用JavaScript“;正则表达式;在Asp.Net中

使用JavaScript“;正则表达式;在Asp.Net中,javascript,Javascript,我想检查用户在Asp.Net页面中输入的密码的密码强度。 我想出了一个javascript正则表达式来实现它。 但我不知道如何使用正则表达式匹配字符串。我已经写了这个代码,但它不工作 我认为这是一个错误 if (true==checkspace.exec(password)) alert("spaces are not allowed"); 看一看 它看起来像是您想要的,因为您希望返回一个布尔值,这取决于是否在字符串中找到该模式 regularExpression.test("my

我想检查用户在Asp.Net页面中输入的密码的密码强度。 我想出了一个javascript正则表达式来实现它。
但我不知道如何使用正则表达式匹配字符串。我已经写了这个代码,但它不工作

我认为这是一个错误

   if (true==checkspace.exec(password))
   alert("spaces are not allowed");
看一看

它看起来像是您想要的,因为您希望返回一个布尔值,这取决于是否在字符串中找到该模式

regularExpression.test("my string to test");

例如,如果要测试密码长度至少为6个字符,并且至少包含一个大写字母、一个小写字母和至少一个数字,则可以使用以下方法:

var passwordRegex = /^.*(?=.{6,})(?=.*[a-z])(?=.*[A-Z])(?=.*[\d\W]).*$/;
var password = 'adg6htyA';
var isPasswordStrong = passwordRegex.test(password);
alert(isPasswordStrong); // shows true

如何检查空格。
/\s/g.test(“要测试的字符串”)将返回true