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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:33:35+00:00 2026-05-14T21:33:35+00:00

Hi I am using jquery 1.4.2 and jquery validate 1.7( http://bassistance.de/jquery-plugins/jquery-plugin-validation/ ) Say I

  • 0

Hi I am using jquery 1.4.2 and jquery validate 1.7(http://bassistance.de/jquery-plugins/jquery-plugin-validation/)

Say I have this example that I just grabbed off some random site(http://www.webreference.com/programming/javascript/jquery/form_validation/)

8     <script type="text/javascript"> 
9       $(document).ready(function() { 
10        $("#form1").validate({ 
11          rules: { 
12            name: "required",// simple rule, converted to {required:true} 
13            email: {// compound rule 
14            required: true, 
15            email: true 
16          }, 
17          url: { 
18            url: true 
19          }, 
20          comment: { 
21            required: true 
22          } 
23          }, 
24          messages: { 
25            comment: "Please enter a comment." 
26          } 
27        }); 
28      }); 
29    </script> 

now is it possible to do something like this

10        $("#form1").validate({ 
           var NameHolder = "name"
11          rules: { 
12            NameHolder: "required",// simple rule, converted to {required:true} 
13            email: {// compound rule 
14            required: true, 
15            email: true 

So basically I want to make sort of a global variable to hold theses rule names( what correspond to the names on that html control).

My concern is the names of html controls can change and it kinda sucks that I will have to go around and change it in many places of my code to make it work again.

So basically I am wondering is there away to make a global variable to store this name. So if I need to change the name I only have to change it in one spot in my javascript file sort of the way stopping magic numbers ?

  • 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-14T21:33:36+00:00Added an answer on May 14, 2026 at 9:33 pm

    From the documentation for “rules”:

    Key/value pairs defining custom rules. Key is the name of an element (or a group of checkboxes/radio buttons), value is an object consisting of rule/parameter pairs or a plain String.

    In your example name: refers to an input element that has the attribute name="name". Therefore, if you consistently name form attributes then using the validate plugin in multiple areas is mostly copy and paste.

    Note that each validation is unique to the form. So if you have a form on page A that has “yourName” and “yourEmail” fields, and a form on page B that has an additional “yourPhone” field, then you would want to write validation rules for each form individually. But you could like use use most of the code from form A for form B.

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

Sidebar

Related Questions

I am using asp.net mvc 2.0 and jquery validate 1.7 ( http://bassistance.de/jquery-plugins/jquery-plugin-validation/ ) What
I'm using the validate plugin from http://bassistance.de/jquery-plugins/jquery-plugin-validation/ What i'm trying to find is a
I'm using the jQuery validation plugin found here: http://plugins.jquery.com/project/validate In my form I have
I'm using CKEditor on a textarea and the jQuery validation plugin ( http://bassistance.de/jquery-plugins/jquery-plugin-validation/ )
I am using the jQuery form validation plugin. The problem I have is that
at the moment i'm using this validation plugin: ( http://www.position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/ ) but when it
Using the jQuery Validation plugin and AJAX, how can I validate the contents of
I'm wondering if it's possible to have the jQuery Validator plugin validate elements that
I'm using the jQuery validate plugin to validate a multi-step form like this one:
I am using the jQuery Validate() plugin. It's been working just fine, however, I

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.