BUGFIX: allow only 2 and 4 digit years.

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@97746 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Mateusz Uzdowski 2010-01-28 20:32:46 +00:00 committed by Sam Minnee
parent c212f40bb5
commit f38e20a7d1
2 changed files with 3 additions and 3 deletions

View File

@ -71,7 +71,7 @@ Behaviour.register({
if(day_value || month_value || year_value){
var value = day_value + '/' + month_value + '/' + year_value;
if(value && value.length > 0 && !value.match(/^[0-9]{1,2}\/[0-9]{1,2}\/[0-90-9]{2,4}\$/)) {
if(value && value.length > 0 && !value.match(/^[0-9]{1,2}\/[0-9]{1,2}\/([0-9][0-9]){1,2}\$/)) {
validationError(_CURRENT_FORM.elements[fieldName+'[Day]'],"$error","validation",false);
return false;
}

View File

@ -56,7 +56,7 @@ HTML;
function validate($validator)
{
if(!empty ($this->value) && !preg_match('/^[0-90-9]{2,4}\-[0-9]{1,2}\-[0-90-9]{1,2}$/', $this->value))
if(!empty ($this->value) && !preg_match('/^([0-9][0-9]){1,2}\-[0-9]{1,2}\-[0-9]{1,2}$/', $this->value))
{
$validator->validationError(
$this->name,
@ -83,7 +83,7 @@ Behaviour.register({
if(day_value || month_value || year_value){
var value = day_value + '/' + month_value + '/' + year_value;
if(value && value.length > 0 && !value.match(/^[0-9]{1,2}\/[0-9]{1,2}\/[0-90-9]{2,4}\$/)) {
if(value && value.length > 0 && !value.match(/^[0-9]{1,2}\/[0-9]{1,2}\/([0-9][0-9]){1,2}\$/)) {
validationError(_CURRENT_FORM.elements[fieldName+'[Day]'],"$error","validation",false);
return false;
}