Giter Club home page Giter Club logo

Comments (4)

ReactiveRaven avatar ReactiveRaven commented on August 20, 2024

I've been thinking about this, but I'm not sure controlling the button is possible. theres a lot of different ways to submit a form ( [type=image], submit, javascript function, etc), and I can't guarantee the button both exists and will be wrapped in bootstrap.

Plus some forms disable the button just after submitting so you don't click twice accidentally, so it might not be enough of an indication that something went wrong.

Hows about adding the "error" class to the form element (bootstrap is smart enough that it doesn't wreck all the fields) and two javascript callbacks?

.jqBootstrapValidation(
    {
        submitFail: function ($form, errors) { 
            alert("invalid!") 
        }, 
        submitSuccess: function ($form, errors) { 
            alert("OK, submitting"); 
        }
    }
);

That way you could set up your own "you have errors!" message in css, or a customised one with the actual errors via JS.

Not done yet, its still an idea. What do you think?

from jqbootstrapvalidation.

brendanheyu avatar brendanheyu commented on August 20, 2024

you could possibly scroll the browser up to that position of the first fail? The behaviour is already in use (of sorts) within bootstrap - scrollspy.

that way the button can exist as the developer had intended...

from jqbootstrapvalidation.

ReactiveRaven avatar ReactiveRaven commented on August 20, 2024

Sorry, I think this is outside of the scope I'd like to keep to.

from jqbootstrapvalidation.

aharonrossano avatar aharonrossano commented on August 20, 2024

as described above.
add submit success function:
submitError: function ($form, event, errors) {
/* ... */
goToByScrollByObj($("form div.control-group.error").first());
},

and add this function to your common javascript file.
function goToByScrollByObj(obj){
// Scroll
if (obj)
$('html,body').animate({
scrollTop: obj.offset().top},
'slow');
}

can probably be slightly improved but this should work.

from jqbootstrapvalidation.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.