jQuery字符长度验证,并具有大写/小写字符

时间:2016-01-28 21:49:37

标签: javascript jquery forms validation utf-8

我有一张表格,我需要确保密码符合某些特定标准。 它必须至少有一个.uppercase,one.lowercase,一个数字,至少8个字符长。这是我到目前为止所提出的,但我有点卡住了。帮助

jQuery(document).ready(function() {
    jQuery("#mysubmit").attr('disabled', 'disabled');
    jQuery("form").keyup(function() {
    // To Disable Submit Button
    jQuery("#mysubmit").attr('disabled', 'disabled');
    // Validating Fields
    var name = jQuery("#name").val();
    var email = jQuery("#email").val();
    var password = jQuery("#mypassword").val();
    console.log('1');
    if (!(name == "" || email == "" || password.length < 8 && value == function(char) {
      return !!/[A-Z]/.exec(char[0]);
    }; )) {
    jQuery("#mysubmit").removeAttr('disabled');
    jQuery("#mysubmit").css({
    "cursor": "pointer",
    "box-shadow": "1px 0px 6px #333"
    });
    }
    });
    console.log('5');
    // On Click Of Submit Button
    jQuery("#mysubmit").click(function() {
    jQuery("#mysubmit").css({
    "cursor": "default",
    "box-shadow": "none"
    });
    alert("Form Submitted Successfully..!!");
    });
    }); 

1 个答案:

答案 0 :(得分:0)

if (!(name == "" && email == "" && password.includes("^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$"))) 

解决了它