Skip to content

added inline form element errorMsg capability #10

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

Merged
merged 1 commit into from
May 10, 2012

Conversation

stevewasiura
Copy link
Contributor

allows form element to have attribute that describes customized error message to display, overwriting default error msg

example: <input 
                data-validation="validate_email"
                data-validation-error-msg="use an email format of name@domain.com"
                type="text"
               >

inline attribute name is set in config section

validate and doValidate functions get that attr value, and if it exists, use it both onblur (each field separately) and onsubmit (whole form at once) methods

allows form element to have attribute that describes customized error message to display, overwriting default error msg
inline attribute name is set in config section
validate and doValidate functions get that attr value and use it both onblur and onsubmit
@victorjonsson
Copy link
Owner

Great!

victorjonsson added a commit that referenced this pull request May 10, 2012
added inline form element errorMsg capability
@victorjonsson victorjonsson merged commit 7902a15 into victorjonsson:master May 10, 2012
@stevewasiura
Copy link
Contributor Author

now I'm confused about the naming of this attribute.
should it be named
"data-error"
or the longer version
"data-validation-error-msg"
(the longer version uses your naming convention starting with word "validation")

your latest example 1.5 on your website seems to use "data-error" to have the effect of a custom inline error message.

i also noticed you use "data-help" as an attribute name.

is "data-error" a standard naming convention from other jQuery examples (or even HTML5 standards / conventions)?

which attribute name do you think we should use?

@victorjonsson
Copy link
Owner

Your 100% right, we should stick to one namespace. My bad, no excuses :)

I have now changed the attribute "data-help" to "data-validation-help", it's more descriptive as well.

The attribute "data-error" is a temporary attribute added by the validation function. After that the script has tested all values it will have a list with failed validations. If the list is empty everything is fine and the form gets posted. If the validation failed it will display the error messages, either in the top of the form or beside each input that has an invalid value. In the case where the error message should be displayed beside the input it will get the error message from the temporary attribute "data-error", created by the function during the validation procedure. Anyhow, there's no reason why we shouldn't use the namespace also in this case, I have therefor changed the temporary attribute name to "data-validation-current-error".

Release 1.5.1 will be pushed to github in a moment.

@stevewasiura
Copy link
Contributor Author

Thanks for listening to my suggestions. This has been a great experience to work with someone smart but not arrogant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants