SOLVED validation server side on core organization field signup

  • OTWD
  • Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
1 month 2 weeks ago #167996 by OTWD
Using j4.4.5 MP 3.6.1 php8.1

I have followed this (have done this successfully on EB)
docs.joomdonation.com/membershippro/basi...eld-data-server-side

Trying to do a server side validation on the "organization" core field
I have setup components/com_osmembership/helper/validator.php
Added the following code for a regex on 5 numbers and 1 letter:
Code:
<?php /**  * @package            Joomla  * @subpackage         Membership Pro  * @author             Tuan Pham Ngoc  * @copyright          Copyright (C) 2010 - 2018 Ossolution Team  * @license            GNU/GPL, see LICENSE.php  */ defined('_JEXEC') or die; Valitron\Validator::addRule('schoolroll', function($field, $value, array $params, array $fields) {     // Validate for exactly 5 digits followed by a single letter     if (!preg_match('/^\d{5}[A-Za-z]$/', $value)) {         return false;     }     return true; }, 'School Roll is 5 digits followed by 1 letter. WARNING! Accounts with incorrect School Rolls will be removed.'); Valitron\Validator::addRule('rule2', function($field, $value, array $params, array $fields) {     if ($value != 9)     {             return false;     }     return true; }, 'The field must has value = 9');

No validation occurs on the MP signup form.
 
I have tried adding "rule2" as a test as well to the Server Validation Rules Field but it allows any value through (see screen shot "organization" core filed has the label "School Roll" 

Success consists of going from failure to failure without loss of enthusiasm.

Please Log in or Create an account to join the conversation.

  • OTWD
  • Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
1 month 2 weeks ago #167997 by OTWD
Actually the validation kicks in after submission and it works perfectly.
Thanks

Success consists of going from failure to failure without loss of enthusiasm.

Please Log in or Create an account to join the conversation.

More
1 month 2 weeks ago #167999 by Tuan Pham Ngoc
Yes. The server validation is only processed when the form is submitted

Regards,

Tuan

Please Log in or Create an account to join the conversation.