diff --git a/lib/WebGUI/Form/Phone.pm b/lib/WebGUI/Form/Phone.pm index 76e959873..540dd17bd 100644 --- a/lib/WebGUI/Form/Phone.pm +++ b/lib/WebGUI/Form/Phone.pm @@ -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; } diff --git a/lib/WebGUI/Form/TimeField.pm b/lib/WebGUI/Form/TimeField.pm index f6870d1cc..256c372b5 100644 --- a/lib/WebGUI/Form/TimeField.pm +++ b/lib/WebGUI/Form/TimeField.pm @@ -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; - diff --git a/t/Form/Phone.t b/t/Form/Phone.t index c540f1f2c..01909aa48 100644 --- a/t/Form/Phone.t +++ b/t/Form/Phone.t @@ -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';