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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:20:56+00:00 2026-06-02T19:20:56+00:00

My form posts to the action even when the textarea is blank. On the

  • 0

My form posts to the action even when the textarea is blank. On the post action, i get this as null.

Also, i have a DI, repository and service architecture.

I have followed the following and still no luck.

MVC3 client validation not working

Here is what i have so far:

Business Entity

namespace Intranet.BusinessEntities
{
    public partial class AnnualReportMessage
    {
        public string Message { get; set; }   
        public int AnnualReportYear { get; set; }
        public string Fice { get; set; }
    }
}

**Following is in Validations Folder**

using System.ComponentModel.DataAnnotations;

namespace Intranet.BusinessEntities
{
    [MetadataType(typeof(AnnualReportMessageMetaData))]
    public partial class AnnualReportMessage
    {
        private class AnnualReportMessageMetaData
        {
            [Required]
            public string Message { get; set; }
        }
    }
}

Following 2 are referenced in the layout

<script type="text/javascript" src="@Url.Script("jqueryMain/jquery.validate.js")"></script>
<script type="text/javascript" src="@Url.Script("jqueryMain/jquery.validate.unobtrusive.min.js")"></script>

Wen.config (in global, not area specific)

<add key="ClientValidationEnabled" value="true"/>
        <add key="UnobtrusiveJavaScriptEnabled" value="true"/>

HTML on Page, i have only made “Message” required, why i am seeing validations for other fields?

<form action="/Sales/AnnualReportNote" id="AnnualReportMessage" method="post">
    <input name="__RequestVerificationToken" type="hidden" value="Q65zfJU+oSODE+qLj0Q0UpfaTId+ENEr+jucyhjWLbk1gnxY0QuTpu7R/lYOGtSxOYJwQkiPryCzgiTekyGikT/YrLQjF6hZXBhKkSF+UVzeAX2PuDrRoJR0pmWf5thL05LlAidHJtRcC3SHHGbxce5dqHSd1zIFpdQfQ3HPu10eUh55jMD4bn0cZeLReJ4P" />
    <input id="Fice" name="Fice" type="hidden" value="XXXXXX" />
    <input data-val="true" data-val-number="The field SetupYear must be a number." data-val-required="The SetupYear field is required." id="SetupYear" name="SetupYear" type="hidden" value="2012" />
    <input data-val="true" data-val-number="The field AnnualReportYear must be a number." data-val-required="The AnnualReportYear field is required." id="Message_AnnualReportYear" name="Message.AnnualReportYear" type="hidden" value="2012" />
    <input id="Message_Fice" name="Message.Fice" type="hidden" value="XXXXXX" />

    <textarea cols="70" data-val="true" data-val-required="The Message field is required." id="Message_Message" name="Message.Message" rows="12">
    </textarea>    

    <div class="distanceBottom"><span class="field-validation-valid" data-valmsg-for="Message.Message" data-valmsg-replace="true"></span></div>

    <input type="image" src="/App_Themes/Main/Images/ResponseAction/Buttons/btn_submit.gif" class="distanceTop" alt="Submit" id="SubmitButton" />
</form>

JavaScript

formSubmit: function ($form, currentForm) {
        if ($form.validate().form()) {
            var $button = $("#" + AnnualReportSpecialEcMessage.enums.submitButtonId);

            jMessage("Processing request...", $button, true, false);
            $.ajax({
                cache: false,
                url: currentForm.action,
                type: currentForm.method,
                data: $form.serialize(),
                error: function (xhr, ajaxOptions, thrownError) {
                    jMessageError(xhr.responseText, $button, false, true);
                },
                success: function (result) {
                    if (result.IsError) {
                        jMessageError(result.Message, $button, false, true);
                    }
                    else {
                        jMessageOK(result.Message, $button, false, false);
                        jMessageHideInterval(3000); //hide after 3 seconds
                    }
                }
            });
        }
    }

Am i missing something here?

  • 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-02T19:20:58+00:00Added an answer on June 2, 2026 at 7:20 pm

    It was jquery.validate.js that had an issue. Either get the latest one or

    Replace

    return $([]).add(this.currentForm.elements)
    .filter(":input")
    

    With

    return $(':input', this.currentForm)
    

    Full working piece

    elements: function() {
                var validator = this,
                    rulesCache = {};
    
                // select all valid inputs inside the form (no submit or reset buttons)
                // workaround $Query([]).add until http://dev.jquery.com/ticket/2114 is solved
                //return $([]).add(this.currentForm.elements)
                //.filter(":input")
                return $(':input', this.currentForm)
                .not(":submit, :reset, :image, [disabled]")
                .not( this.settings.ignore )
                .filter(function() {
                    !this.name && validator.settings.debug && window.console && console.error( "%o has no name assigned", this);
    
                    // select only the first element for each name, and only those with rules specified
                    if ( this.name in rulesCache || !validator.objectLength($(this).rules()) )
                        return false;
    
                    rulesCache[this.name] = true;
                    return true;
                });
            },
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Form element: $Form=new Zend_Form; $Form->setAction($this->view->url(array('controller'=>'auth','action'=>'create'),null,true)) ->setMethod('post') ->setAttrib('id','auth-form') ->removeAttrib('enctype'); As can be
I have this HTML: <form action='uploadhandle.php' method='POST' enctype=multipart/form-data> <input type='file' class='fileinput' id='photo1' name='photo1'> <input
I have this form: $form = array( '<form name=backup-form class=backup-form method=post action=#>', '<fieldset class=backup-fields>',
I have a post html form, and the action is index.php, which is the
$('form').submit(function(){ this.action=http://www.sitename.com/post; return false; }); having altered the action attribute of the form ,i
In a php-script i have a form, method is post, action-attribute is empty, which
I have an HTML form: <form action='process.php' method='post'> <input type='checkbox' name='check_box_1' /> Check me!<br>
I have a form, like so: <form action= method=post> <select name=pageType> <option value=main>Main Page</option>
I am returning File result from action triggered by the form post event. I
I'm trying to access the post target action in a jquery function. example: <form

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.