XF 2.1 XenForo way to validate a simple custom <xf:form> ? (regex)

Earl

Well-known member
I have a simple form like this in a default notification block
HTML:
{{ phrase('your_account_is_currently_awaiting_confirmation_confirmation_message_sent_to_x', {'phone': $xf.visitor.phone}) }}<br />
<xf:form action="{{ link('canonical:account-confirmation/phone') }}" ajax="true" class="block">
    <xf:textboxrow name="phone" type=""
                   label="{{ phrase('phone_number') }}" required="required" hint="{{ phrase('required') }}" />
    <xf:textboxrow name="c"
                   label="{{ phrase('verification_code') }}" required="required" hint="{{ phrase('required') }}" />

    <xf:submitrow submit="{{ phrase('confirm') }}" icon="login" />
</xf:form>
<a href="{{ link('account-confirmation/resendPhone') }}" data-xf-click="overlay">{{ phrase('resend_confirmation_message') }}</a>

And I know we can use <xf:textboxrow> 's type attribute and It automatically validates the form field against search, email, url, number, but what about regex?
I'm trying to verify the phone numbers that only have a specific prefix using regex. What's the XenForo way to make this work?

Note: I know I can add custom fields for phone numbers and they have convenient ways for using validations but I don't want to include the phone number in the registration form. I want to add it to the next step, so I have to use a simple form with simple regex validation.
 
Last edited:
Back
Top Bottom