[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [13014] tweak formvalidator
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [13014] tweak formvalidator |
Date: |
Wed, 15 Apr 2015 13:29:28 +0000 |
Revision: 13014
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=13014
Author: sigurdne
Date: 2015-04-15 13:29:27 +0000 (Wed, 15 Apr 2015)
Log Message:
-----------
tweak formvalidator
Modified Paths:
--------------
branches/dev-syncromind/phpgwapi/inc/class.jquery.inc.php
Modified: branches/dev-syncromind/phpgwapi/inc/class.jquery.inc.php
===================================================================
--- branches/dev-syncromind/phpgwapi/inc/class.jquery.inc.php 2015-04-15
07:33:13 UTC (rev 13013)
+++ branches/dev-syncromind/phpgwapi/inc/class.jquery.inc.php 2015-04-15
13:29:27 UTC (rev 13014)
@@ -158,28 +158,79 @@
return "phpgroupware.{$widget}" . ++self::$counter;
}
- public static function formvalidator_generate($modules = array()) {
+ public static function formvalidator_generate($modules = array(),
$form_id = 'form', $errorMessagePosition_id = '')
+ {
+ // keep track of number of times loaded per pageload
+ static $times_loaded = 0;
+
self::load_widget('validator');
- $modules_js = '"' . implode(',', $modules) . '"';!
- $div = "'".'#error-message-wrapper'."'";
- $messages = '$'.'('.$div.')';
-
+ $modules_js = '"' . implode(',', $modules) . '"';
+
+ if($errorMessagePosition_id)
+ {
+ $errorMessagePosition =
"$('#{$errorMessagePosition_id}')";
+ }
+ else
+ {
+ $errorMessagePosition = "'top'";
+ }
+
+ $translation = '';
+ if(!$times_loaded)//first time only
+ {
+ //TODO: add translations
+ $translation = <<<JS
+
+ var validateLanguage = {
+ errorTitle : 'Form submission failed!',
+ requiredFields : 'You have not answered all
required fields',
+ badTime : 'You have not given a correct time',
+ badEmail : 'You have not given a correct
e-mail address',
+ badTelephone : 'You have not given a correct
phone number',
+ badSecurityAnswer : 'You have not given a
correct answer to the security question',
+ badDate : 'You have not given a correct date',
+ lengthBadStart : 'You must give an answer
between ',
+ lengthBadEnd : ' characters',
+ lengthTooLongStart : 'You have given an answer
longer than ',
+ lengthTooShortStart : 'You have given an
answer shorter than ',
+ notConfirmed : 'Values could not be confirmed',
+ badDomain : 'Incorrect domain value',
+ badUrl : 'The answer you gave was not a
correct URL',
+ badCustomVal : 'You gave an incorrect answer',
+ badInt : 'The answer you gave was not a
correct number',
+ badSecurityNumber : 'Your social security
number was incorrect',
+ badUKVatAnswer : 'Incorrect UK VAT Number',
+ badStrength : 'The password isn\'t strong
enough',
+ badNumberOfSelectedOptionsStart : 'You have to
choose at least ',
+ badNumberOfSelectedOptionsEnd : ' answers',
+ badAlphaNumeric : 'The answer you gave must
contain only alphanumeric characters ',
+ badAlphaNumericExtra: ' and ',
+ wrongFileSize : 'The file you are trying to
upload is too large',
+ wrongFileType : 'The file you are trying to
upload is of wrong type',
+ groupCheckedRangeStart : 'Please choose
between ',
+ groupCheckedTooFewStart : 'Please choose at
least ',
+ groupCheckedTooManyStart : 'Please choose a
maximum of ',
+ groupCheckedEnd : ' item(s)'
+ };
+JS;
+ }
+
$js = <<<JS
-
+ {$translation}
$(document).ready(function ()
{
- $.validate({
- modules : $modules_js,
-
errorMessagePosition : $messages,
- form: '#form',
- validateOnBlur
: false,
-
scrollToTopOnError : false,
-
errorMessagePosition : 'top'
- });
+ $.validate({
+ modules : {$modules_js},
+ form: '#{$form_id}',
+ validateOnBlur : false,
+ scrollToTopOnError : false,
+ errorMessagePosition :
{$errorMessagePosition},
+ language : validateLanguage
+ });
});
JS;
$GLOBALS['phpgw']->js->add_code('', $js);
- return $output;
+ $times_loaded ++;
}
/**
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [13014] tweak formvalidator,
Sigurd Nes <=