'digits' filter not working

Home Forums Quform PHP 'digits' filter not working

This topic is: resolved
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #12944
    Xavi
    Participant

    I am trying to add a filter to phone numbers so I tried your filter “digits”.

    Seems like it is not working (does nothing) when the user sends the form.

    HTML code:
    ————————————————————————————
    <div class=”quform-element quform-element-text”>
    <div class=”quform-spacer”>
    <label for=”tel”>Phone</label>
    <div class=”quform-input”>
    <input id=”tel” type=”text” name=”tel” />
    </div>
    </div>
    </div>
    ————————————————————————————

    PHP (process.php) code:
    ————————————————————————————
    $tel = new Quform_Element(‘tel’, ‘Phone’);
    $tel->addFilter(‘trim’);
    $tel->addFilter(‘digits’, array(‘allowWhiteSpace’ => true));
    $form->addElement($tel);
    ————————————————————————————

    Any clue?

    Thank you for your time,

    Xavi Alsina

    #12968
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #12982
    Xavi
    Participant

    My bad, i meant that I want to validate the phone number by digits, but seems is not working either.

    So if the user types something like: “asdf” on phone number it validates and send the form. I know that it strips anything that isn’t digits, but I would like to alert the user that is not a valid phone number (since they did not type any digits).

    Updated code (process.php):

    $tel = new Quform_Element(‘tel’, ‘Telèfon’);
    $tel->addFilter(‘trim’);
    $tel->addValidator(‘digits’);
    $tel->addFilter(‘digits’, array(‘allowWhiteSpace’ => true));
    $form->addElement($tel);

    Thank you for your time,

    Xavi Alsina

    #13002
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #13027
    Xavi
    Participant

    Thank you, working flawless Ally!

    You can close the ticket if needed.

    Cheers

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy