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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:44:34+00:00 2026-06-13T13:44:34+00:00

I have a textbox for username in a form, when user enter the username,

  • 0

I have a textbox for username in a form, when user enter the username, i need to check if that username is already in data base. I’m thinking to catch the blur event of the text box & to write a javascript function to query & check in database. I’m trying some thing like this:

@html.textboxfor(x=>x.UserName, new{@id="UserName"})

<script type="text/javascript">
$(document).ready(function(){$('#UserName').blur("then some code here");})

</script>

Now I need to know if I’m following the right way? If so then please let me know how can I call a action method which will interact with the database within the blur function or whats the right way? Thanks in advance.

  • 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-13T13:44:35+00:00Added an answer on June 13, 2026 at 1:44 pm

    Yes, that looks right. You can use a JQuery Ajax call, along with the Url.Action helper method.

    $(document).ready(function(){
        $('#UserName').blur(function() {
            var name = this.value;
            $.get(@Url.Action("VerifyUsername") + "?name=" + value, function(result) {
                if (result.ok == false) {
                    $("#message").text("Username '" + name + "' is already taken, please try another");
                }
            });
        });
    });
    

    This will call an action VerifyUsername in the current controller. It assumes that the action returns JSON like {ok:true} to verify the name:

    public ActionResult VerifyUsername(string name)
    {
        bool isOk;
        // check the database
        return new JsonResult() {
            Data = new { ok: isOk },
            JsonRequestBehavior = JsonRequestBehavior.AllowGet
        };
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I have a textbox that takes a username input. When the user submits
I have a textbox that I am defining as <%= Html.TextBox(Username, Model.Form.Username, new {
I have a login form that contains a username textbox and a password box.
I have register form. I want to check new username that is in db
I have a asp:textbox taking a Username that is part of a Signup form
I have a form with an entry textbox that is identified as username .
I have the form to check username availability Where form should submit data only
I have a simple login form, username and password. Basically, When a user is
I have a simple password reset form that has a username field, and below
I have a form that after the user inputs a user name and password

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.