Home › Forums › Quform PHP › 'digits' filter not working
- This topic has 4 replies, 2 voices, and was last updated 10 years ago by Xavi.
- AuthorPosts
- November 4, 2014 at 9:10 am #12944XaviParticipant
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
November 6, 2014 at 7:57 am #12968AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
November 7, 2014 at 8:48 am #12982XaviParticipantMy 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
November 11, 2014 at 1:03 pm #13002AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
November 12, 2014 at 1:56 pm #13027XaviParticipantThank you, working flawless Ally!
You can close the ticket if needed.
Cheers
- AuthorPosts
- You must be logged in to reply to this topic.