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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:10:27+00:00 2026-05-21T20:10:27+00:00

Hi I have a form in which the Username field needs to be checked

  • 0

Hi I have a form in which the Username field needs to be checked for availability using AJAX.
Here is my code..

 <% using (Html.BeginForm()) { %>
        <%: Html.ValidationSummary(true, "Account creation was unsuccessful. Please correct the errors and try again.") %>
        <div>
            <fieldset>
                <legend>Account Information</legend>

                <div class="editor-label">
                    <%: Html.LabelFor(m => m.UserName) %>
                </div>
                <% using (Ajax.BeginForm("Checkavailability", new AjaxOptions { UpdateTargetId = "textEntered" }))
                   { %>
 <div class="editor-field">
                    <%: Html.TextBoxFor(m => m.UserName) %>
                    <%: Html.ValidationMessageFor(m => m.UserName) %>
                </div>
  <input type="submit" value="Check Avail" id="Submitt"/><br />
  <span id="textEntered">Nothing Entered</span>
<% } %>


                <div class="editor-label">
                    <%: Html.LabelFor(m => m.Email) %>
                </div>
                <div class="editor-field">
                    <%: Html.TextBoxFor(m => m.Email) %>
                    <%: Html.ValidationMessageFor(m => m.Email) %>
                </div>

                <div class="editor-label">
                    <%: Html.LabelFor(m => m.Password) %>
                </div>
                <div class="editor-field">
                    <%: Html.PasswordFor(m => m.Password) %>
                    <%: Html.ValidationMessageFor(m => m.Password) %>
                </div>

                <div class="editor-label">
                    <%: Html.LabelFor(m => m.ConfirmPassword) %>
                </div>
                <div class="editor-field">
                    <%: Html.PasswordFor(m => m.ConfirmPassword )%>
                    <%: Html.ValidationMessageFor(m => m.ConfirmPassword) %>
                </div>

                <p>
                    <input type="submit" value="Register" />
                </p>
            </fieldset>
        </div>
    <% } %>

The problem is when I click on check avil button the validation appears.. Is there a way to submit just the ajax form and update without submitting the main form?? or any way to implement my check availability logic?

  • 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-21T20:10:27+00:00Added an answer on May 21, 2026 at 8:10 pm

    I removed the AJAX.BeginForm an added Ajax.ActionLink which dosent submit the form .. instead it passes a single paramater to the controller which I need to check.. Here is the code..

     <% using (Html.BeginForm()) { %>
            <%: Html.ValidationSummary(true, "Account creation was unsuccessful. Please correct the errors and try again.") %>
    
                <fieldset>
                       <div class="editor-label">
                        <%: Html.LabelFor(m => m.UserName) %>
                    </div>
     <div class="editor-field">
                        <%: Html.TextBoxFor(m => m.UserName) %>
                        <%: Html.ValidationMessageFor(m => m.UserName) %>
                    </div>
          <%= Ajax.ActionLink("Checkavailability", "Checkavailability", new { UserName = "" }, new AjaxOptions { UpdateTargetId = "textEntered" }, new { id = "u" })%>
    
    
    
      <span id="textEntered">Nothing Entered</span>
    
    
    
                    <p>
                        <input type="submit" value="Register" />
                    </p>
    
    
                </fieldset>
    
        <% } %>
    

    Below is the jQuery which is used to set the parameters being passed

      <script type="text/javascript">
    
           $(document).ready(function () {
               $('#UserName').blur(function () {
                   changeActionURL();
               });
    
           });
    
    
    
           function changeActionURL() {
    
               if ($("#UserName").val() == "") {
                   alert('Please enter your email to check availablity');
               }
               else {
    
    
                   var url = '<%= new UrlHelper(ViewContext.RequestContext).Action("Checkavailability", "Account") %>' + '?UserName=' + $("#UserName").val();
    
                   $("#u").attr('href', url);
               }
           }
    
    
    
    
    </script>
    

    the controller is..

    public string Checkavailability(string UserName)
            {
                if (UserName != "Enter text" && !String.IsNullOrEmpty(UserName))
                {
                    string userName = UserName.ToLower();
                    NorthwindEntities dbContext = new NorthwindEntities();
                    var query = from p in dbContext.Employees
                                where p.FirstName.ToLower() == userName
                                select p;
                    IEnumerable<Employee> rec = query.ToList();
    
                    if (rec.Count() == 0)
                    {
                        return "You entered: \"" + UserName.ToString() + "\" available ";
                    }
                    else
                    {
                        return "You entered: \"" + UserName.ToString() + "\" already exists " +
                          DateTime.Now.ToLongTimeString();
                    }
    
                }
    
                return String.Empty;
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created one jsp form which contains the username textfield. On the click
I have a sign-up form which prompts for the first name, last name, username,
i have one signup form where i have three field username,password and email address
I have a form which is linked with various stylesheets. I have two stylesheets
I have a form which changes the inputfields depending on a radio-button. for text
I have a form which is used to insert/display and update . In the
I have a form which takes both the user details and an image uploaded
I have a form which I create manually (a lot of JavaScript in it...).
I have a form which users must fill out and submit. The controller action
I have a form which encapsulates all the functionality, but works with a concrete

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.