I am trying to validate the phone number while adding a new customer user to my OTRS system. The phone number should be 10 digits, and it should accept only digits. I have added the following code in add action in Admincustomeruser.pm inside module but its not working:
if ($GetParam{UserMobile} && length($GetParam{UserMobile}) lt 10)
{
$Errors{UserMobileInvalid} = 'test';
$Errors{ErrorType} = 'Invalid mobile number' . 'ServerErrorMsg';
}
How to validate phone number while adding a new customer user
-
- Znuny guru
- Posts: 5018
- Joined: 13 Mar 2011, 09:54
- Znuny Version: 6.0.x
- Real Name: Renée Bäcker
- Company: Perl-Services.de
- Contact:
Re: How to validate phone number while adding a new customer user
Instead of should work
Code: Select all
if ($GetParam{UserMobile} && length($GetParam{UserMobile}) lt 10)
Code: Select all
if ($GetParam{UserMobile} && length($GetParam{UserMobile}) =~ m{\A[0-9]{10}\z} )
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
-
- Znuny advanced
- Posts: 138
- Joined: 20 Jan 2011, 11:21
- Znuny Version: [...],6.x, Znuny 7
- Real Name: Peter
- Company: maxence business consulting GmbH
- Location: Dormagen
Re: How to validate phone number while adding a new customer user
Hi,
Maybe it is better to match the field's content, not it's length:
Maybe it is better to match the field's content, not it's length:
Code: Select all
if ($GetParam{UserMobile} && $GetParam{UserMobile} =~ m{\A[0-9]{10}\z} )
-
- Znuny guru
- Posts: 5018
- Joined: 13 Mar 2011, 09:54
- Znuny Version: 6.0.x
- Real Name: Renée Bäcker
- Company: Perl-Services.de
- Contact:
Re: How to validate phone number while adding a new customer user
Sure, that's what I had in mind... I never like mondays
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de