Prev: errors while installing pear for php on windows
Next: HTML_QuickForm2_Renderer_Array: Element IDs as array key?
From: zia mohaddes on 2 May 2010 05:03 Hello everyone, I have a quick question regarding the form->addGroupRule. I am currently creating a field where it requires the user to enumer a number and the number must be a 1 decimal point ( i.e 1.2). I am using : $this->form->addGroupRule($field . "_group", array(array(array("Numbers only, please", 'numeric')))); but I am not sure how to add the 'decimal point' validation rule to the rule above. I highly appreciate any hints or feedback in this regard! regards, daniel
From: Alexey Borzov on 2 May 2010 09:56 Hi Zia, On 02.05.2010 13:03, zia mohaddes wrote: > I have a quick question regarding the form->addGroupRule. I am currently > creating a field where it requires the user to enumer a number and the > number must be a 1 decimal point ( i.e 1.2). > > I am using : > > $this->form->addGroupRule($field . "_group", array(array(array("Numbers > only, please", 'numeric')))); > > but I am not sure how to add the 'decimal point' validation rule to the rule > above. > > I highly appreciate any hints or feedback in this regard! 'numeric' rule is just the Regex rule with a predefined regular expression (BTW, it does allow numbers with decimal points). If you want to only allow one digit after a decimal point, you'll have to do your own regexp, probably taking the existing one as inspiration.
From: zia mohaddes on 2 May 2010 10:01 Hi alexey, Thank you for your response! I just googled to find out more about the regex used in the 'numeric' function. Would it be possible for you to provide me with an example of a sample regex used ,so I can get inspired and create my own? Thank you kindly for your help! regards, zia On Sun, May 2, 2010 at 9:56 AM, Alexey Borzov <borz_off(a)cs.msu.su> wrote: > Hi Zia, > > > On 02.05.2010 13:03, zia mohaddes wrote: > >> I have a quick question regarding the form->addGroupRule. I am currently >> creating a field where it requires the user to enumer a number and the >> number must be a 1 decimal point ( i.e 1.2). >> >> I am using : >> >> $this->form->addGroupRule($field . "_group", array(array(array("Numbers >> only, please", 'numeric')))); >> >> but I am not sure how to add the 'decimal point' validation rule to the >> rule >> above. >> >> I highly appreciate any hints or feedback in this regard! >> > > 'numeric' rule is just the Regex rule with a predefined regular expression > (BTW, it does allow numbers with decimal points). If you want to only allow > one digit after a decimal point, you'll have to do your own regexp, probably > taking the existing one as inspiration. >
From: Alexey Borzov on 2 May 2010 10:11
Hi Zia, On 02.05.2010 18:01, zia mohaddes wrote: > Thank you for your response! I just googled to find out more about the regex > used in the 'numeric' function. Would it be possible for you to provide me > with an example of a sample regex used ,so I can get inspired and create my > own? Look in the HTML/QuickForm/Rule/Regex.php file, all the predefined regular expressions are there. > On Sun, May 2, 2010 at 9:56 AM, Alexey Borzov<borz_off(a)cs.msu.su> wrote: > >> Hi Zia, >> >> >> On 02.05.2010 13:03, zia mohaddes wrote: >> >>> I have a quick question regarding the form->addGroupRule. I am currently >>> creating a field where it requires the user to enumer a number and the >>> number must be a 1 decimal point ( i.e 1.2). >>> >>> I am using : >>> >>> $this->form->addGroupRule($field . "_group", array(array(array("Numbers >>> only, please", 'numeric')))); >>> >>> but I am not sure how to add the 'decimal point' validation rule to the >>> rule >>> above. >>> >>> I highly appreciate any hints or feedback in this regard! >>> >> >> 'numeric' rule is just the Regex rule with a predefined regular expression >> (BTW, it does allow numbers with decimal points). If you want to only allow >> one digit after a decimal point, you'll have to do your own regexp, probably >> taking the existing one as inspiration. >> > |