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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:58:46+00:00 2026-05-27T17:58:46+00:00

I have a jquery validation plugin. I don’t want my form to submit if

  • 0

I have a jquery validation plugin. I don’t want my form to submit if there are certain things that are not right about it. I don’t want it to submit if it doesn’t have a certain date field or another certain varChar(25) field. I also want to make sure that it doesn’t submit if a certain field has over 4000 characters in it. If that same field has no characters then it is ok to submit the form. For that to work with jquery validation, would I need to make that a requried validation?

$("#temp1").validate({
        rules: {
            HospitalFinNumber: {
                required: true,
                minlength: 6
            },
            DateOfBirth: {
                required: true
            },
            AdmitDate: {
                required: true
            },
            Comment: {
                maxlength: 4000
            }
        },
        messages: {
            HospitalFinNumber: 'Please Enter a Hospital Fin number',
            DateOfBirth: 'Please enter a valid Date Of Birth',
            AdmitDate: 'Please select an Admit Date'
        }

Notice how I have the first 3 fields as required and the last one is not required. I have tried to submit the form and it does indeed post back to the server if there is more than 4000 characters in that field. That would be a problem. I need to make this field conditionally required somehow. Also, if required is set to true, you should not be able to submit the form with those fields filled out right?

  • 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-05-27T17:58:46+00:00Added an answer on May 27, 2026 at 5:58 pm

    You have two options here; either write custom validation classes, or use required’s dependency expression instead of just true. I think the latter is prettier.

    See the docs on this. Here’s how to make your Comment field optionally required, depending on length:

    required: function(element) {
        return $(element).val().length > 4000;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small jQuery plugin that I use for form AJAX validation. There
I know there's the jQuery validation plugin. But I don't need something that extensive.
I have a form using jquery validation plugin. My submit button has an ajax
Does jQuery validation plugin have some dependencies? For example, I saw blogposts that said
I am using jquery validation plugin for form validation. I have added a custom
I have a Reset Password form being validated by the jQuery Validation plugin. Everything
I am using jquery validation plugin to validate my form. I have one field
I'm using the jQuery validation plugin and the form uses ajax to submit the
I'm trying to use the Jquery validation plugin to validate my form. I have
I am using jquery validation plugin. I have an html that looks like: <h2>Select

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.