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 6382401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:31:03+00:00 2026-05-25T02:31:03+00:00

I am validating an objects name to ensure it is unique. To perform this

  • 0

I am validating an objects “name” to ensure it is unique. To perform this I am using the jQuery bassisstance validation plugin. I issue a SYNCHRONOUS ajax call during the validation method to verify uniqueness as follows

jQuery.validator.addMethod("new_user_role_name_unique", function(value) {
    var role_name_valid = true;
    jQuery.ajax(
    {
        type: "GET",
        async: false,
        data: "name=" + encodeURIComponent(value),
        url: '/user_roles/0/name_taken',
        success: function (result) {
            var taken = JSON.parse(result);
            role_name_valid = !taken
        }
    });
    return role_name_valid;
}, I18n.t('user_role_name_already_used'));

When I type a name in the “name” text field and then immediately click on the submit button defined below, I would expect the method addUserRole to be called:

      <button id='user_role_add_button' class='rounded green' type='button' onclick="addUserRole()" name='add' value='add'>
         <span><%= t(:user_role_add_button) %></span>
      </button>

However, the method addUserRole is not called. If I type a “name” however and then lose focus on the name text field, prior to clicking the button the method is called with no drama.

So in essence, my problem is when the name textfield has focus, I have to double click the save button to ensure addUserRole method is called.

Does anyone know why my click event seems to be lost on the first click under these circumstances, but not the second? I cant have the user double click on the button to save.

  • 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-05-25T02:31:03+00:00Added an answer on May 25, 2026 at 2:31 am

    Synchronous ajax calls block UI events and you may lose some events when doing that. It would be much better to use an async ajax call and let the user events happen in real-time.

    Without the actual relevant HTML from your page and all participating event handlers, it’s hard to follow the sequence you are describing to offer more info.

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

Sidebar

Related Questions

Can I automatically validate complex child objects when validating a parent object and include
I want to invoke a validation function inside the entities objects right before they
In my rails app I use the validation helpers in my active record objects
My question is regarding MVC 2 custom validation. I'm stuck on a particular issue
We have a ASP.NET MVC 3 application that uses unobtrusive jQuery validation. The page
I am using https://github.com/bcardarella/client_side_validations to validate my sign up form. I am validating the
I am trying to perform validation on some fields by binding a function to
I have read through this which helped me narrow down my validation problems to
We are using a validation framework (something we have cooked up ourselves) which allows
Long post - sorry.... I'm doing input validation for a WCF service and using

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.