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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T13:50:10+00:00 2026-05-16T13:50:10+00:00

could you take a look at this http://jsbin.com/osolo/ please? If you enter a letter

  • 0

could you take a look at this http://jsbin.com/osolo/ please?

If you enter a letter in Min Age rather than a number then hit submit this validates using jquery validator using a regular expression in a custom validation method, this works but i’m now looking to make it a little more dynamic.

In the custom validation method the line

var data = $(element).metadata(); 

grabs meta data from the element being validated, what i would like to do is use the

data.validateOptions.regex

as the regex to test with (i can’t see this being a problem), what i can see being a problem is that if the field doesn’t validate, rather than using a message that is supplied when calling

jQuery.validator.addMethod(name, method, message)

i’d like to use

data.validateOptions.message

as the error message from within the custom method, can anyone point me in the right direction please?

Thanks

OneShot

  • 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-16T13:50:10+00:00Added an answer on May 16, 2026 at 1:50 pm

    I think Alex’s answer won’t work because strings are immutable in JS.

    It’s close though. Starting with Alex’s code, if you create a closure containing the data object (or just a message string) and also a function returning the message, you can pass the function as the third argument to the addmethod call.
    Like so:

    (function() {
        var data = {};
        var messager = function() {
            return data.validateOptions.message;
        };
        jQuery.validator.addMethod("perorgproperty", function(value, element) { 
            debugger; 
            //alert('testing perorgproperty'); 
            data = $(element).metadata();
            return this.optional(element) || /^\d+$/i.test(value); 
        }, messager);
    })();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could someone possibly take a look at this: http://jsfiddle.net/VkFRU/4/ and explain the console output
Well Im stucked at this point.please take a look at this http://jsfiddle.net/karthik64/5jhgF/3/ Okay first
Can someone take a look at this menu http://www.abmoldremediationnj.com/3 and let me know how
could anyone take a look at this for me? Problem: trying to output a
Take a look at this page: http://jqeedu.tuxfamily.org/test/index.php . You'll see a < between the
Take a look at the example here: http://www.brianhare.com/physics/so.html Take a look at console.log where
Could someone take a look at the following link of a work in progress
Could someone take a quick look, why the text in the dark grey isn't
Take a look at this page and click on the arrows to activate the
Take a look at the snippet below. Is there any function I could write

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.