Skip to content Skip to sidebar Skip to footer

How Do I Put An Object(associatvie Array) In An Object(associatve Array)

Here is my third mis-guided attempt: var check = { pattern : patterns = { name: /^[a-zA-Z-\s]{1,20}$/, email: /^[a-zA-Z0-9._(-)]+@[a-zA-Z0-9.(-)]+\.[a-zA-Z]{1,4}$/,

Solution 1:

If this is the structure you want:

Objectpattern: 
    Objectaml: /<(.+)_([a-z]){1}>$/email: /^[a-zA-Z0-9._(-)]+@[a-zA-Z0-9.(-)]+\.[a-zA-Z]{1,4}$/name: /^[a-zA-Z-\s]{1,20}$/pass: /.{6,40}/url: /^[(-)\w&:\/\.=\?,#+]{1,}$/

The right syntax is :

var check = {
  pattern : {
    name: /^[a-zA-Z-\s]{1,20}$/,
    email: /^[a-zA-Z0-9._(-)]+@[a-zA-Z0-9.(-)]+\.[a-zA-Z]{1,4}$/,
    pass: /.{6,40}/,
    url:  /^[(-)\w&:\/\.=\?,#+]{1,}$/,
    aml:  /<(.+)_([a-z]){1}>$/
    }
  };

Solution 2:

var check = {
    pattern: {
        patterns: {
            name: /^[a-zA-Z-\s]{1,20}$/,
            email: /^[a-zA-Z0-9._(-)]+@[a-zA-Z0-9.(-)]+\.[a-zA-Z]{1,4}$/,
            pass: /.{6,40}/,
            url:  /^[(-)\w&:\/\.=\?,#+]{1,}$/,
            aml:  /<(.+)_([a-z]){1}>$/
        }
    }
};

http://jsfiddle.net/dbrecht/NcbHZ/

...Although your naming convention (pattern.patterns) doesn't really make sense, unless there's something I'm not seeing there.

Post a Comment for "How Do I Put An Object(associatvie Array) In An Object(associatve Array)"