New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support default display for {0} #207

Closed
niceue opened this Issue Jan 13, 2016 · 0 comments

Comments

Projects
None yet
1 participant
@niceue
Copy link
Owner

niceue commented Jan 13, 2016

The default config:
messages: {
    0: "This field",
    required: "{0} is required."
}

When you not set the field display, the render message will be "This field is required.",
otherwise the {0} will be replaced by your display setting.
eg.

<!-- The message is "Email is required." -->
<input name="name" data-rule="Email: required">

<!-- The message is "This field is required." -->
<input name="name" data-rule="required">
You can also config {0} with a fallback like {0|fallback_display}.

eg.

$("#myform").validator({
    // if you set the display as "Name", then the message is "Name is required."
    // if you not set a display, then the message will be "This field is required."
    messages: {
        required: "{0|This field} is required."
    },
    fields: {
        name: "required"
    }
});

@niceue niceue added the improve label Jan 13, 2016

@niceue niceue added this to the 0.10.1 milestone Jan 13, 2016

niceue referenced this issue Jan 13, 2016

@niceue niceue closed this Jan 13, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment