mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
ENHANCEMENT: use Validator::get_javascript_validator_handler() to check if the handler is turned on before doing either js or php validation
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@97792 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
4d6a0e61d0
commit
4939a0a4dc
@ -93,6 +93,9 @@ class CompositeDateField extends DateField {
|
||||
}
|
||||
|
||||
function jsValidation() {
|
||||
if(Validator::get_javascript_validator_handler() == 'none') {
|
||||
return '';
|
||||
}
|
||||
$formID = $this->form->FormName();
|
||||
$error1 = _t('CompositeDateField.VALIDATIONJS1', 'Please ensure you have set the');
|
||||
$error2 = _t('CompositeDateField.VALIDATIONJS2', 'correctly.');
|
||||
@ -106,8 +109,7 @@ Behaviour.register({
|
||||
var day_value = \$F(_CURRENT_FORM.elements[fieldName+'[date]']);
|
||||
var month_value = \$F(_CURRENT_FORM.elements[fieldName+'[month]']);
|
||||
var year_value = \$F(_CURRENT_FORM.elements[fieldName+'[year]']);
|
||||
if(day_value == 'NotSet' && month_value == 'NotSet' && year_value == 'NotSet') return true;
|
||||
else if(day_value == 'NotSet') {
|
||||
if(day_value == 'NotSet') {
|
||||
var err = "$day";
|
||||
var el = _CURRENT_FORM.elements[fieldName+'[date]'];
|
||||
} else if(month_value == 'NotSet') {
|
||||
@ -133,6 +135,9 @@ JS;
|
||||
}
|
||||
|
||||
function validate($validator) {
|
||||
if(Validator::get_javascript_validator_handler() == 'none') {
|
||||
return true;
|
||||
}
|
||||
// TODO Implement server-side validation
|
||||
if($this->value == null) {
|
||||
$validator->validationError($this->name,_t('Form.VALIDATIONALLDATEVALUES',"Please ensure you have set all date values"),"validation");
|
||||
|
@ -58,6 +58,10 @@ HTML;
|
||||
}
|
||||
|
||||
function jsValidation() {
|
||||
if(Validator::get_javascript_validator_handler() == 'none') {
|
||||
return '';
|
||||
}
|
||||
|
||||
$formID = $this->form->FormName();
|
||||
$error = _t('DateField.VALIDATIONJS', 'Please enter a valid date format (DD/MM/YYYY).');
|
||||
$error = 'Please enter a valid date format (DD/MM/YYYY) from dmy.';
|
||||
@ -68,13 +72,12 @@ Behaviour.register({
|
||||
var day_value = \$F(_CURRENT_FORM.elements[fieldName+'[Day]']);
|
||||
var month_value = \$F(_CURRENT_FORM.elements[fieldName+'[Month]']);
|
||||
var year_value = \$F(_CURRENT_FORM.elements[fieldName+'[Year]']);
|
||||
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-9][0-9]){1,2}\$/)) {
|
||||
validationError(_CURRENT_FORM.elements[fieldName+'[Day]'],"$error","validation",false);
|
||||
return false;
|
||||
}
|
||||
var value = day_value + '/' + month_value + '/' + year_value;
|
||||
|
||||
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;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -56,6 +56,9 @@ HTML;
|
||||
|
||||
function validate($validator)
|
||||
{
|
||||
if(Validator::get_javascript_validator_handler() == 'none') {
|
||||
return true;
|
||||
}
|
||||
if(!empty ($this->value) && !preg_match('/^([0-9][0-9]){1,2}\-[0-9]{1,2}\-[0-9]{1,2}$/', $this->value))
|
||||
{
|
||||
$validator->validationError(
|
||||
@ -70,6 +73,9 @@ HTML;
|
||||
}
|
||||
|
||||
function jsValidation() {
|
||||
if(Validator::get_javascript_validator_handler() == 'none') {
|
||||
return '';
|
||||
}
|
||||
$formID = $this->form->FormName();
|
||||
$error = _t('DateField.VALIDATIONJS', 'Please enter a valid date format (DD/MM/YYYY).');
|
||||
$error = 'Please enter a valid date format (DD/MM/YYYY) from dmy.';
|
||||
@ -80,15 +86,12 @@ Behaviour.register({
|
||||
var day_value = \$F(_CURRENT_FORM.elements[fieldName+'[Day]']);
|
||||
var month_value = \$F(_CURRENT_FORM.elements[fieldName+'[Month]']);
|
||||
var year_value = \$F(_CURRENT_FORM.elements[fieldName+'[Year]']);
|
||||
if(day_value || month_value || year_value){
|
||||
var value = 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-9][0-9]){1,2}\$/)) {
|
||||
validationError(_CURRENT_FORM.elements[fieldName+'[Day]'],"$error","validation",false);
|
||||
return false;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user