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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:26:52+00:00 2026-05-19T04:26:52+00:00

if i execute the following code i get a cannot convert to object error;

  • 0

if i execute the following code i get a cannot convert to object error;
Uncaught exception: TypeError: Cannot convert ‘validation.messages.field’ to object

$.fn.validate = function(validation) {
    $.each(validation.rules, function(field, fieldRules){
        $.each(fieldRules, function(rule, ruleValue){
            var fieldValue = $('[name=' + field + ']').val();
            if (eval(rule + '(fieldValue, ruleValue)') == false){
                alert(validation.rules.field.rule);
                return false;
            }else{
                return true;
            };
        });
    });
}

the problem is the

alert(validation.messages.field.rule);

‘field’ = ‘persoon_voornaam’ and ‘rule’ = ‘required’
and validation.messages.persoon_voornaam.required works just fine.

What am i doing wrong?

validation is a JSON that look like this:

{
    rules: {
        persoon_voornaam: {
            required: true, 
            minlength: 5,
        },
        postcode_bestemming: {
            required: true, 
            minlength: 7,
        },
    },
    messages: {
        persoon_voornaam: {
            required: 'Dit veld is verplicht',
            minlengt: 'Dit veld moet minstens 5 lang zijn', 
        },
    }
}
  • 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-19T04:26:53+00:00Added an answer on May 19, 2026 at 4:26 am

    It has to be:

    alert(validation.rules[field][rule])
    

    To clarify:

    validation.rules is an object while field is a variable with the string 'persoon_voornaam'.

    validation.rules.persoon_voornaam is an object and the same as validation.rules['persoon_voornaam'].

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

Sidebar

Related Questions

When I execute the following code: Preferences.userRoot().nodeExists(strNodeName); I get an exception : java.util.prefs.BackingStoreException: Cannot
I'm using the following code to execute a query in Lucene.Net var collector =
I have the following code: $bind = new COM(LDAP://CN=GroupName,OU=Groups,OU=Division,DC=company,DC=local); When I execute it from
The following PL/SQL will not execute and simply returns 'Invalid Argument' as an error.
I have been trying to get the following code to work(everything is defined in
The following code executes a simple insert command. If it is called 2,000 times
The following code executes properly when the data key has no data to send,
When the following two lines of code are executed in a bash script, ls
How do I execute the following shell command using the Python subprocess module? echo
On all my Windows servers, except for one machine, when I execute the following

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.