We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42074
    • 7 Posts
    Hi
    I try to validate a field with regexp test : ^((\+|00)33\s?|0)[679](\s?\d{2}){4}$ (field zip in example)
    I've tried all syntax in my snippet call, no one is working, there it is :
    [[!UpdateProfile?
        &submitVar=`updatememberbtn`
        &user=`[[!getReqParam? &name=`user_id` &type=`REQUEST`]]`
        &preHooks = `onBeforeMemberCreate`
        &postHooks = `onAfterMemberCreate`
        &reloadOnSuccess = `0`
        &useExtended=`0`
        &validate=`
    	spam:blank,
    	username:required,
    	card_type:required:isNumber,
    	firstname:required,
    	lastname:required,
    	gender:required:isNumber,
    	dob:required:regexp=^\d{1,2}\/\d{1,2}\/\d{4}$,
    	email:email:required,
    	mobilephone:required:regexp=^((\+|00)33\s?|0)[679](\s?\d{2}){4}$,
    	zip:required:regexp=^0[1-9]|[1-8][0-9]|9[0-8]|2A|2B[0-9]{3}$`
    ]]
    
      • 3749
      • 24,544 Posts
      I'm not sure if it will work, but the regexp value would need a closing ^ at the end.

        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 42074
        • 7 Posts
        Quote from: BobRay at Jul 02, 2014, 11:48 PM
        I'm not sure if it will work, but the regexp value would need a closing ^ at the end.

        Nop, not working like this ^0[1-9]|[1-8][0-9]|9[0-8]|2A|2B[0-9]{3}^
          • 3749
          • 24,544 Posts
          Does the "zip" you are testing actually start with a 0?

          Have you tested the regex in a snippet or at a web regex tester?

          What happens without the 'required' option?
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 42074
            • 7 Posts
            Ok
            I think there is a bug in Login Extra

            When i do this in loginvalidator.class.php :

                public function regexp($key,$value,$expression) {
                    echo $expression;
            		die;
                	preg_match($expression,$value,$matches);
                    return !empty($matches) && !empty($matches[0]) == true ? true : $this->_getErrorMessage($key,'vTextRegexp','register.not_regexp',array(
                        'field' => $key,
                        'value' => $value,
                        'regexp' => $expression,
                    ));
                }




            for regexp ^\d{1,2}\/\d{1,2}\/\d{4}^ he's writing \d{1
            I think the comma make trouble. I keep searching, any help is welcome
              • 3749
              • 24,544 Posts
              It could be a bug. I don't think a lot of people use it.
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting