Jude
Jude

Reputation: 2433

JQuery Validation - Check if the textbox has special character

How can I validate the textbox Name does not include '@'?

 rules: {
            Name: {
                required: true,

            },
            Email: {
                required: true,
                email: true
            },
            Password1: {
                minlength: 6
            },
 }

Upvotes: 0

Views: 731

Answers (1)

Arun P Johny
Arun P Johny

Reputation: 388326

Try the pattern rule

rules: {
    Name: {
        required: true,
        pattern: /^[^@]+$/
    },
    Email: {
        required: true,
        email: true
    },
    Password1: {
        minlength: 6
    },
},
messages: {
    Name: {
        pattern: 'Name should not contain @'
    }
}

Demo: Fiddle

Upvotes: 3

Related Questions