Fix a bug in TimeField.
Add support for Brazilian phone numbers and extensions to Phone
This commit is contained in:
parent
c772fa0d3a
commit
1ad61ac861
3 changed files with 5 additions and 8 deletions
|
|
@ -79,7 +79,7 @@ Returns a string filtered to allow only digits, spaces, and these special charac
|
|||
sub getValueFromPost {
|
||||
my $self = shift;
|
||||
my $value = $self->session->form->param($self->get("name"));
|
||||
if ($value =~ /^[\d \.\-\+\(\)]+$/ and $value =~ /\d/) {
|
||||
if ($value =~ /^[x\d \.\-\+\(\)]+$/ and $value =~ /\d/) {
|
||||
return $value;
|
||||
}
|
||||
return undef;
|
||||
|
|
@ -96,7 +96,7 @@ Renders a phone number field.
|
|||
sub toHtml {
|
||||
my $self = shift;
|
||||
$self->session->style->setScript($self->session->config->get("extrasURL").'/inputCheck.js',{ type=>'text/javascript' });
|
||||
$self->set("extras", $self->get('extras') . ' onkeyup="doInputCheck(this.form.'.$self->get("name").',\'0123456789-()+ \')" ');
|
||||
$self->set("extras", $self->get('extras') . ' onkeyup="doInputCheck(this.form.'.$self->get("name").',\'x0123456789-()+ \')" ');
|
||||
return $self->SUPER::toHtml;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -131,12 +131,8 @@ sub toHtmlAsHidden {
|
|||
my $self = shift;
|
||||
return WebGUI::Form::Hidden->new($self->session,
|
||||
name=>$self->get("name"),
|
||||
value=>secondsToTime($self->get("value"))
|
||||
value=>$self->session->datetime->secondsToTime($self->get("value"))
|
||||
)->toHtmlAsHidden;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
|
|
|||
|
|
@ -36,11 +36,12 @@ tie %testBlock, 'Tie::IxHash';
|
|||
PHONE1 => [ "503\n867\n5309", undef, 'newline separation'],
|
||||
PHONE2 => [ '503 867 5309', 'EQUAL', 'valid: space separation'],
|
||||
PHONE3 => [ '503.867.5309', 'EQUAL', 'valid: dot separation'],
|
||||
PHONE4 => [ '503 867 5309 x227', undef, 'WRONG: extension syntax rejectd'],
|
||||
PHONE4 => [ '503 867 5309 x227', 'EQUAL', 'valid: extension syntax rejectd'],
|
||||
PHONE5 => [ '()()()', undef, 'invalid: no digits'],
|
||||
PHONE6 => [ '------', undef, 'invalid: no digits'],
|
||||
PHONE7 => [ "\n", undef, 'invalid: no digits'],
|
||||
PHONE8 => [ "++++", undef, 'invalid: no digits'],
|
||||
PHONE9 => [ "0xx31 3456 1234", 'EQUAL', 'Brazilian long distance'],
|
||||
);
|
||||
|
||||
my $formClass = 'WebGUI::Form::Phone';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue