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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:44:19+00:00 2026-05-11T10:44:19+00:00

The following HTML form successfully utilizes jQuery’s form validation, displaying This field is required

  • 0

The following HTML form successfully utilizes jQuery’s form validation, displaying ‘This field is required’ to the right of the form field if left blank, and ‘Please enter at least 2 characters’ if fewer than 2 characters were entered. However, instead of the validation metadata being specified using the class and minlength attributes on the ‘cname’ form input field, I’d like to use jQuery’s ‘rules’ API instead, where the rules are specified in the body of the validate function. Thanks in advance:

    <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'                      'http://www.w3.org/TR/html4/loose.dtd'> <html> <head>   <script src='/lib/js/jquery.js'></script>   <script src='/lib/js/jquery.validate.js'></script>   <script>   $(document).ready(function(){$('#commentForm').validate(     /*      rules/messages here     */     );}     );   </script> </head> <body>   <form id='commentForm' method='get' action=''>  <fieldset>    <legend>A simple comment form with submit validation and default messages</legend>    <p>      <label for='cname'>Name</label>      <em>*</em><input id='cname' name='name' size='25' class='required' minlength='2' />    </p>    <p>      <input class='submit' type='submit' value='Submit'/>    </p>  </fieldset>  </form> </body> </html> 
  • 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. 2026-05-11T10:44:20+00:00Added an answer on May 11, 2026 at 10:44 am

    The examples contained in this blog post do the trick.

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

Sidebar

Related Questions

I'm currently uploading a single file successfully with the following form: <html> <body> <form
I use the following code of jQuery plugin: Validation : <!DOCTYPE html PUBLIC -//W3C//DTD
Given the following HTML form: <form id=myform> Company: <input type=text name=Company value=ACME, INC./> First
When you do the following in an HTML form: <input name=one[] value=foo /> <input
For the following HTML: <form name="myForm"> <label>One<input name="area" type="radio" value="S" /></label> <label>Two<input name="area" type="radio"
Suppose I have the following HTML: <form id=myform> <input type='checkbox' name='foo[]'/> Check 1<br/> <input
I have the following multi-select box in a HTML form, where user can select
I have a simple MVC form with the following elements: <%= Html.TextBox(FechaInicio) %> Which
The following HTML looks as required in Firefox 2 & 3 and IE7. The
I am using Jquery form plugin to upload file in Ajax request.File is successfully

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.