You are here

function password_policy_constraint_alphanumeric_js in Password Policy 6

Same name and namespace in other branches
  1. 7 constraints/constraint_alphanumeric.inc \password_policy_constraint_alphanumeric_js()

Javascript portion.

File

constraints/constraint_alphanumeric.inc, line 41
Password policy constraint callbacks.

Code

function password_policy_constraint_alphanumeric_js($constraint, $uid) {
  $s = '';
  $s .= "  var i=0;\n";
  $s .= "  var num=0;\n";
  $s .= "  var chr=\"\";\n";
  $s .= "  while(i<value.length) {\n";
  $s .= "    chr=value.charAt(i);\n";
  $s .= "    if(chr.toUpperCase() != chr.toLowerCase() || \"1234567890\".indexOf(chr) != -1) {\n";
  $s .= "      num++;\n";
  $s .= "    }\n";
  $s .= "    i++;\n";
  $s .= "  }\n";
  $s .= "  if (num<{$constraint}) {\n";
  $s .= "    strength=\"low\";\n";
  $s .= "    msg.push(translate.constraint_alphanumeric);\n";
  $s .= "  }\n";
  return $s;
}