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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:17:58+00:00 2026-06-14T12:17:58+00:00

I have a Form where I successfully use unobtrusive-validation with the [remote] annotation. I

  • 0

I have a Form where I successfully use unobtrusive-validation with the [remote] annotation.
I have other fields in the Form with [required] annotation in the model but I don’t want client-side validation for these fields.

I only want server-side validation for [required] fields

I haven’t found a solution and I wonder if it’s easily feasible?

EDIT :

A part of my code

Part of my model :

I would like the first field : “Email” use Unobtrusive-validation and the second one : “PasswordHash” only use server-side validation even if it has [required] annotation.

Finally, i don’t want an AJAX error message for all my form ‘s fields.

[Required(ErrorMessageResourceType = typeof(Project.Resources.Models.Accounts.User), ErrorMessageResourceName = "EMAIL_REQUIRED")]
[Display(Name = "EMAIL_DISPLAY", ResourceType = typeof(Project.Resources.Models.Accounts.User))]
[Remote("EmailExists", "User", "An account with this email address already exists.")]
public string Email { get; set; }

[Required(ErrorMessageResourceType = typeof(Project.Resources.Models.Accounts.User), ErrorMessageResourceName = "PASSWORDHASH_REQUIRED")]
[DataType(DataType.Password)]
[Display(Name = "PASSWORDHASH_DISPLAY", ResourceType = typeof(Project.Resources.Models.Accounts.User))]
public string PasswordHash { get; set; }

Part of the action in Controller
Server-side validation :

    [HttpPost]
    public ActionResult Register(User user)
    {

        if (ModelState.IsValid )
        {   

            DataContext.User.Add(user);
            DataContext.SaveChanges();

            return RedirectToAction("Index");
        }

        return View(user);
    }

Ajax validation :

public JsonResult EmailExists(string email)
{
    User user = DataContext.User.SingleOrDefault(x => x.Email == email);

    return user == null ?
        Json(true, JsonRequestBehavior.AllowGet) :
        Json(
            string.Format("an account for address {0} already exists.",
            email), JsonRequestBehavior.AllowGet);
}

Part of the view :

 @using (Html.BeginForm())
 {
    @Html.ValidationSummary(true)


    <div class="editor-label">
        @Html.LabelFor(model => model.Email)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.Email)
        @Html.ValidationMessageFor(model => model.Email)
    </div>

    <div class="editor-label">
        @Html.LabelFor(model => model.PasswordHash)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.PasswordHash)
        @Html.ValidationMessageFor(model => model.PasswordHash)
    </div>

    <p>
        <input type="submit" name="op" id="edit-submit" value="@Project.Resources.Views.User.Register.SUBMIT_FORM" class="form-submit art-button" />
    </p>
 }

When I click on the sumbit button i would like a server-side validation.

And for some specific fields like Email i would like an Ajax Validation.

  • 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-14T12:17:59+00:00Added an answer on June 14, 2026 at 12:17 pm

    there might be better ways, but one way to accomplish this is to do the following

    @using (Html.BeginForm("Register", "Home", FormMethod.Post, new { id = "registerForm" }))
     {
        @Html.ValidationSummary(true)
    
    
        <div class="editor-label">
            @Html.LabelFor(model => model.Email)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Email)
            @Html.ValidationMessageFor(model => model.Email)
        </div>
    
        <div class="editor-label">
            @Html.LabelFor(model => model.PasswordHash)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.PasswordHash)
            @Html.ValidationMessageFor(model => model.PasswordHash)
        </div>
    
        <p>
            <input type="submit" name="op" id="edit-submit" value="@Project.Resources.Views.User.Register.SUBMIT_FORM" class="form-submit art-button" />
        </p>
     }
    
    <script type="text/javascript">
    
        // add the rules for the fields that you want client-side validation on
        // leave out the fields that you dont want client-side validation. they will be validated 
        // on server side.
        $("#registerForm").validate({
            rules: {
                Email: { required: true }
            },
            messages: {
                Email: { required : "Email is required" }
            }
        });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Ext.Form.Panel successfully but I want to use Ext.form.field.File this time. I was
I have a message that I want to fadeIn when a form is successfully
I am building a form, where required field validation must have been checked. I
I have successfully built a login form using ajax and want to add a
I have a form in which user can add more fields, as he want...
i have use java script successfully running in my project but when i have
I have a form that I want to use to collect user information. I
I have a form that when submitted successfully generates new elements on the page
Hi I have a Sticky form that after successful completion I want to clear
I have form where are 2 input fields and then i have dynamic dataTables

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.