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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:16:58+00:00 2026-06-13T08:16:58+00:00

Our app is using ASP.NET MVC 3 and I wanted to take advantage of

  • 0

Our app is using ASP.NET MVC 3 and I wanted to take advantage of creating a custom validation attribute that worked on both the client and server side.

The user will enter a physician number in an input field. The value is then used to check and see if the physician number entered is actually valid. This requires a call to the database. I have an ajax call inside my validation method. This works fine but only when async is set to false.

<script type="text/javascript">
    $.validator.setDefaults({
        debug: true,
        onkeyup: false,
        onclick: false,
        focusInvalid: false
    })

    $.validator.addMethod('physician', function (value, element, params) 
    {
        var request = $.ajax({
            type: "POST",
            url: "@Url.Content("~/patient/GetPhysicianById")",
            data: { physicianNumber: value },
            async: false,
            beforeSend: function(xjhr, settings) {                                                                            
                var siblings = $(element).siblings('.physician-response');                    
                //$(siblings[0]).html("<img src=\"/content/images/ajax-loader.gif\" />");            
            }                
        });

        console.log(request);            

        if(request.responseText == "0")
            return false;

        return true;
    });

    $.validator.unobtrusive.adapters.add('physician', ['param1', 'param2'], function (options) {
        options.rules['physician'] = options.params;
        options.messages['physician'] = options.message;
    });

</script>

On the form, there are three different physician inputs that will trigger this method. Every time blur is lost, it runs these calls again. Also runs when the user clicks save. I’m not certain if this is really the proper approach, or I should handle this validation in a separate manner.

  • 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-13T08:16:59+00:00Added an answer on June 13, 2026 at 8:16 am

    You might take a look at the [Remote] attribute to perform this kind of validation.

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

Sidebar

Related Questions

I have an ASP.NET app that sits on our intranet, using the WindowsIdentity to
We will be using custom Silverlight 4.0 controls on our ASP.NET MVC web page
My team is considering building our next web app using the ASP.NET MVC framework.
http://www.asp.net/learn/mvc/tutorial-39-cs.aspx We are using the above guide to implement some validation in our ASP.NET
We've implemented a background service in our Asp.Net web app that receives messages from
we are using the asp.net profiles provider in our app and I need to
We have written Web application using ASP.NET MVC, which will be hosted in our
I have developed a web app in ASP.NET MVC which we are using internally.
Background: I am working on an ASP.NET MVC app that has 3 partials (based
We are using Tiny MCE editor on our .NET MVC app. All was done

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.