F
F
freecoder-en2017-07-16 17:47:38
MySQL
freecoder-en, 2017-07-16 17:47:38

What's wrong with validation?

I am writing a validation for login ..
I get an error about test () , I don’t understand why the error is that this is a non-function .. What could be the problem ?

(function(){

    $.validator.addMethod("NICKNAME", function (value) {
        var reg_ex = "^[a-z0-9_-]{3,15}$";
        return reg_ex.test(value);
    }, "Wrong nick name format , matched nicknames 1. mkyong34 2. mkyong_2002 3. mkyong-2002 4. mk3-4_yong! ");

    $.validator.addMethod("EMAIL", function (value) {
        var reg_ex = "^\[email protected][a-zA-Z_]+?\.[a-zA-Z]{2,3}$";
        return reg_ex.test(value);
    }, "Wrong email format, Matches: [email protected] | [email protected] | [email protected] !");

    $.validator.addMethod("PASSWORD", function (value) {
        var reg_ex = "((?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%]).{6,20})";
        return reg_ex.test(value);
    }, "Wrong password format, matched password 1. [email protected] 2. mkYOn12$! ");


    $("#login").validate({
        rules: {
            nick_name: {
                required:true,
                minlength: 5,
                NICKNAME:true
            },
            email: {
                required: true,
                EMAIL:true
            },
            password: {
                required:true,
                rangelength:[8, 12],
                number:true,
                PASSWORD:true
            }
        },
        messages : {
            nick_name: {
                required:"This field is required to be filled!",
                minlength:"The minimum length of nickname 5 characters!",
            },
            email :{
                required:"This field is required to be filled!",
            },
            password : {
                required:"This field is required to be filled!",
                rangelength:"The length of password must be 8-12 digits",
                number:"Password must be a number!",
            }
        }
    });
})();


Uncaught TypeError: reg_ex.test is not a function.  
Exception occurred when checking element nname, check the 'NICKNAME' method.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Antonio Solo, 2019-01-25
@solotony

I would also look at what collation is set and perhaps explicitly set it
, and if "Vitallevi" is not your typo, then you need to use LIKE

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question