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

  • Home
  • SEARCH
  • 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 8599615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:26:07+00:00 2026-06-12T01:26:07+00:00

I want to add a required field validation on textboxes, I’m not using any

  • 0

I want to add a required field validation on textboxes, I’m not using any model parameters(Annotations) for these textboxes. How to achieve this?

Following is my code:

@using (Html.BeginForm())
{
  <h1> 3D Pay Örnek Sayfa</h1>
  <table class="tableClass">
  <tr class="trHeader">
    <td>Test</td>
    <td>@Html.TextBox("TestIt")</td>
  </tr>
  </table>
}
  • 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-12T01:26:08+00:00Added an answer on June 12, 2026 at 1:26 am

    Well, you really should use a model, but if you insist doing things by hand, I’d still recommend using the jquery validation plugin.

    An example based on http://docs.jquery.com/Plugins/Validation#Example:

    (Note: the bit you’re looking for is @Html.TextBox("TestIt", "", new { @class="required" }), which add the class=”required” attribute to the textbox, which in turn tells jquery validate that it’s a required field.)

    <html>
    <head>
        <script src="http://code.jquery.com/jquery-latest.js"></script>
        <script type="text/javascript" src="http://jzaefferer.github.com/jquery-validation/jquery.validate.js"></script>
        <style type="text/css">
            * { font-family: Verdana; font-size: 96%; }
            label { width: 10em; float: left; }
            label.error { float: none; color: red; padding-left: .5em; vertical-align: top; }
            p { clear: both; }
            .submit { margin-left: 12em; }
            em { font-weight: bold; padding-right: 1em; vertical-align: top; }
        </style>
        <script>
            $(document).ready(function(){
               $("form").validate();
            });
        </script>
    </head>
    <body>
    @using (Html.BeginForm())  
    {  
        <center>  
            <h1> 3D Pay Örnek Sayfa</h1>  
                <table class="tableClass">  
                    <tr class="trHeader">  
    
                        <td>Test</td>  
                        <td>@Html.TextBox("TestIt", "", new { @class="required" })</td>  
                    </tr>  
                </table>  
        </center>  
        <input type="submit" id="SubmitData" name="SubmitData" value="Submit" />
    }
    </body>
    </html>
    

    Please remember this is just client side validation – you also need to validate on the server side too. As you’re not using a model, this will probably mean some custom controller code to validate each input.

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

Sidebar

Related Questions

I want to add the data-val-required and data-val attributes to an @html.textbox or an
Does the row below is required in AssemblyInfo.cs if i want to add an
I am using an Ajax.BeginForm with unobtrusive validation. I want to give the user
I am using the jQuery Validation plugin I want one of my fields to
I'm using MVC3 with unobtrusive validation. I have a field that the user is
I am using jquery validation plugin to validate my form. I have one field
I would like to replace validation message for all model properties that have [Required]
I want add UIGestureRecognizerDelegate to UIWebView,but failed. if [self.view addsubView:webView]; So UIWebView is ok,but
I want add new Feed item on entity persist and update. I write this
I want add label to every row in tableview at right side of the

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.