Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am attempting to validate a form that contains fields with name attributes containing square brackets []. It's a requirement that I cannot change the name attribute to something else, and it just seems messy trying to validate via ID or ClassName..

How would I go about validating the w as the following example? As of now it does not work (makes my entire page completely dissappear due to an error.

$("#loginForm").validate({
    rules: {

        login[username]: {
            required: true,
            email: true
        }
    },
    messages: {

        login[username]: {
            required: "Please provide an email",
            email: "Please enter a valid email address"
        }
    }
});
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
394 views
Welcome To Ask or Share your Answers For Others

1 Answer

using login[username] inside a javascript object is not valid syntax. Use quotes around it to make it valid "login[username]"


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...