Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8212347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:43:32+00:00 2026-06-07T10:43:32+00:00

I am using thedersen’s Backbone.validation plugin to provide validation. The validation itself works so

  • 0

I am using thedersen’s Backbone.validation plugin to provide validation.

The validation itself works so far and gets executed when I submit the form. I only don’t success about letting the view listen on validation errors.

The howto says that you can listen on validation events with:

model.bind('validated:invalid', function(model, attrs) {
   // do something
});

Source: http://thedersen.com/backbone.validation/#events/validated

define(['jquery', 'underscore', 'backbone', "models/security/user", 'text!templates/security/registration.html'], function($, _, Backbone, SecurityUserModel, Template){

    var SecurityRegistrationView;

    SecurityRegistrationView = Backbone.View.extend({
        initialize: function(){
            this.model = new SecurityUserModel();
            this.render();
            Backbone.Validation.bind(this);
        },
        render: function(){
            $(this.el).append(Template);
        },
        events: {
            "submit form": "submit"
            , "validated:valid": "valid"
            , "validated:invalid": "invalid"
        },
        submit: function(e){
            e.preventDefault();

            var username, email, password;
            username = $("#_user_username").val();
            email = $("#_user_email").val();
            password = $("#_user_password").val();

            this.model.set('username', username);
            this.model.set('email', email);
            this.model.set('password', password);

            this.model.validate();

            console.log(this.model.validate());
        },
        invalid: function(){
            $("input").addClass("inputError");
            alert(" ");
        },
        valid: function(){
            alert(" ");
            this.model.save(function(){
                // server validation callback...
            });
        }

    });

    return SecurityRegistrationView;
});

So how can I use the model related event in a form?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T10:43:33+00:00Added an answer on June 7, 2026 at 10:43 am

    The events validated:valid and validated:invalid are not DOM-events, but Backbone events. The Backbone.View events hash is meant for handling DOM-events (source) whereas the model.bind is used to tap onto events triggered by the particular model.

    So remove these lines from the events-hash:

    events: {
      "submit form": "submit", // LEAVE THIS AS IT IS A DOM EVENT
      "validated:valid": "valid", // REMOVE THIS
      "validated:invalid": "invalid" // REMOVE THIS
    }
    

    and add this to your initialize function

    initialize: function(){
      this.model = new SecurityUserModel();
      this.render();
      Backbone.Validation.bind(this);
    
      this.model.bind('validated:valid', this.valid); // NEW
      this.model.bind('validated:invalid', this.invalid); // NEW
    }
    

    Now you are tapping into the model events the correct way.

    Hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using MVC2 I have an AJAX form which is posting to a bound model.
using chrome and ff so far have made a nasty glitch when using scrollTo
Using Entity Framework CodeFirst, how do I create a created datetime column that gets
Using CRM 4, I have an entity form that contains a tab with an
Using VB6 I am using checkbox and combobox in a Form. When i click
Using the C# Facebook SDK 5.0.3 everything works fine whit the client.Get(/me). But when
Using Spring MVC, do interceptors only intercept defined controller mappings or can they also
Using ASP.NET MVC there are situations (such as form submission) that may require a
Using Android 2.1+. I have a service that gets killed from time to time
Using jQuery the jquery plugin along with the easing plugin. I have a series

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.