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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:05:31+00:00 2026-06-13T22:05:31+00:00

I have AJAX Form in MVC 3. In Index view: <div id=ajaxcontactform> <% Html.RenderPartial(ContactForm,

  • 0

I have AJAX Form in MVC 3.

In Index view:

<div id="ajaxcontactform">
      <% Html.RenderPartial("ContactForm", Model); %>
</div>

AJAX form on ContactForm Partial View

<% using (Ajax.BeginForm("Contact", new AjaxOptions()
{
   UpdateTargetId = "ajaxcontactform",
   OnBegin = "ShowProcessing",
   OnComplete = "HideProessing",
   InsertionMode = InsertionMode.Replace
}))
{%>
<%: Html.ValidationSummary()%>
<%: Html.TextBoxFor(m => m.Name, new { Class = "contacttextform" })%>
<%}%>

My controller:

 [HttpPost]
    public ActionResult Contact(ContactForm form)
    {
        if (Request.IsAjaxRequest())
        {
             // on error
            if (!ModelState.IsValid)
                return PartialView("ContactForm", form);

           // TODO: My data processing code here  

           // return partial view on success
             return PartialView("ContactForm", new ContactFormModel());   
         }
   }

my client side custom validation JavaScript code:
I just referenced this file in master page. This code runs once when DOM get loaded/created once.

    $.validator.addMethod("phonenumber", function (value, element, params) {

    if (!value)
        return true;
    var regex = /^[\s\d\+\(\)]+$/;
    return regex.test(value);
   });
   jQuery.validator.unobtrusive.adapters.addBool("phonenumber");

My client side validation works fine when I first load my page. However, once i submit my form successfully and try to submit my form again . My client side validation doesn’t work and my form validate it server side.

I want to bind my client side validation again after adding new element or re-render my partial view.

Also, how should I clear my form values once it submitted successfully.

Thanks,

  • 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-13T22:05:32+00:00Added an answer on June 13, 2026 at 10:05 pm

    You could subscribe to the OnSuccess method in the AjaxOptions and reattach the client side validation of the newly added elements using the $.validator.unobtrusive.parse method:

    function OnSuccess(result) {
        $('form').removeData('validator');
        $('form').removeData('unobtrusiveValidation');
        $.validator.unobtrusive.parse('form');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Inside of an asp.net mvc partial view, I have an Ajax form that posts
i need help with ASP MVC. I have: <% using (Html.BeginForm(null,null,FormMethod.Post)) {%> <p> <input
I have an ajax form in asp.net mvc which is as simple as this:
I am new to ASP.NET MVC, particularly ajax operations. I have a form with
I would like to have Ajax form in Rails so i'm using form_remote_tag. The
I have an Ajax form that updates a div when submitted with a submit
I have a search that returns an AJAX(MVC AJAX Form) grid, and, in the
I'm posting a form to an MVC action using jquery Ajax. Server side, I
I've been having a problem regarding using AJAX with Spring MVC. I have a
I have set up a form using TinyMCE in my MVC website. To do

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.