Skip to content
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

Minlength 1, on blur not triggering validation error #1358

Closed
ericjswanson opened this issue Dec 15, 2014 · 9 comments
Closed

Minlength 1, on blur not triggering validation error #1358

ericjswanson opened this issue Dec 15, 2014 · 9 comments

Comments

@ericjswanson
Copy link

<!DOCTYPE html>
 <html lang="en">
 <head>
    <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
    <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.13.1/jquery.validate.js"></script>
    <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.13.1/additional-methods.js"></script>
 </head>

 <body>
    <form id="simpleForm">
        <label for="first_name" class="left font-14px">First Name</label>
        <input name="eProfileFName" type="text" placeholder="John" id="registration-container" class="text-input-height form-control-lg" id="first_name" value="">
    </form>

    <script>
        $('#simpleForm').validate({
            onsubmit: false,            // Disable default form submit handling. 
            focusCleanup: true,         // Automatically clear error when user focuses back in field
            onFocusOut: true,           // Validate when we leave field
            onkeyup: false,             // We're not using keyup during validation
            errorElement: "div",        // Instead of using framework's default <label> tag, use <div> to hold msg
            errorClass: "validationMsg",// Use our css instead of default "error" class
            rules: {                    // Defines the rules for each input field.
                eProfileFName: {        // Name of input field
                    required: true,
                    minlength: 1,
                    maxlength: 30
                }
            },
            messages: {                 // Override plugin's default messages with our own
                eProfileFName:          "Please enter the first name (alpha only)"
            }
        });
    </script>
 </body>
 </html>
@ericjswanson
Copy link
Author

Expected behavior is that when you load the page no error is shown, then when you focus on the field and focus out the validation message should be shown.

@staabm
Copy link
Member

staabm commented Dec 16, 2014

the behaviour you want is not related to min/max length, but the required validator... right?

@jzaefferer
Copy link
Collaborator

onFocusOut: true is invalid, the option only accepts boolean false and a function.

See also #1266 (comment)

@ericjswanson
Copy link
Author

@staabm the behavior I want is related to both, but the goal is to show the validation error when the field is empty and neither minLength 1 or required is providing this.

@staabm
Copy link
Member

staabm commented Dec 16, 2014

@jzaefferer what do you think of providing validation for those switches/settings, so we get a console error/exception when unexpected values are used?

@jzaefferer
Copy link
Collaborator

Or we actually support a value of true.

@jzaefferer jzaefferer reopened this Dec 16, 2014
@staabm
Copy link
Member

staabm commented Dec 16, 2014

So, true would be like the current default?

@edegagne
Copy link

So if 'true' is not supported, then how do we get the onfocusout to work?

Because this line no longer works (and true is not accepted):

onfocusout: function(element){ $(element).valid(); }

So is there a work around to get validation on individual elements by using onfocusout ?? This is a real showstopper for us if anyone can suggest something.

@jzaefferer
Copy link
Collaborator

I'm sorry for the lack of activity on this issue. Instead of leaving it open any longer, I decided to close old issues without trying to address them, to longer give the false impression that it will get addressed eventually, especially after several years with no activity. It doesn't mean I'm abandoning the project, just that I'm unable to work through 200+ open issues with the little time I can afford to spend on this project.

To the reporter (or anyone else interested in this issue): If you're still affected by the same issue, please consider opening a new issue, with a testpage that demonstrates the issue with a current version of the plugin. Even better, make an attempt to fix the issue yourself, and improve the project by sending a pull request. This may seem daunting at first, but you'll likely learn some useful skills that you can apply elsewhere as well. And you can help keep this project alive. We've documented how to do these things, too. A patch is worth a thousand issues!

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

No branches or pull requests

4 participants