Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

#$ [#29669] Consistent form validation notifications. Thanks Roland

  • Loading branch information...
commit a3d79b20f80467ff71890a7637edebd231cba193 1 parent b5710c0
Roland Dalmulder authored infograf768 committed
Showing with 27 additions and 49 deletions.
  1. +0 −2  administrator/components/com_categories/views/category/tmpl/edit.php
  2. +0 −3  administrator/components/com_contact/views/contact/tmpl/edit.php
  3. +0 −2  administrator/components/com_content/views/article/tmpl/edit.php
  4. +0 −2  administrator/components/com_modules/views/module/tmpl/edit.php
  5. +1 −3 administrator/components/com_newsfeeds/views/newsfeed/tmpl/edit.php
  6. +0 −2  administrator/components/com_templates/views/source/tmpl/edit.php
  7. +1 −4 administrator/components/com_weblinks/views/weblink/tmpl/edit.php
  8. +1 −0  administrator/language/en-GB/en-GB.lib_joomla.ini
  9. +0 −2  administrator/templates/hathor/html/com_categories/category/edit.php
  10. +0 −3  administrator/templates/hathor/html/com_contact/contact/edit.php
  11. +0 −2  administrator/templates/hathor/html/com_content/article/edit.php
  12. +0 −2  administrator/templates/hathor/html/com_modules/module/edit.php
  13. +0 −2  administrator/templates/hathor/html/com_newsfeeds/newsfeed/edit.php
  14. +0 −3  administrator/templates/hathor/html/com_weblinks/weblink/edit.php
  15. +2 −4 components/com_content/views/form/tmpl/edit.php
  16. +0 −3  components/com_weblinks/views/form/tmpl/edit.php
  17. +3 −0  installation/CHANGELOG
  18. +1 −0  language/en-GB/en-GB.lib_joomla.ini
  19. +3 −0  libraries/joomla/html/behavior.php
  20. +14 −0 media/system/js/validate-uncompressed.js
  21. +1 −7 media/system/js/validate.js
  22. +0 −3  templates/beez3/html/com_weblinks/form/edit.php
View
2  administrator/components/com_categories/views/category/tmpl/edit.php
@@ -29,8 +29,6 @@
if (task == 'category.cancel' || document.formvalidator.isValid(document.id('item-form'))) {
<?php echo $this->form->getField('description')->save(); ?>
Joomla.submitform(task, document.getElementById('item-form'));
- } else {
- alert('<?php echo $this->escape(JText::_('JGLOBAL_VALIDATION_FORM_FAILED'));?>');
}
}
</script>
View
3  administrator/components/com_contact/views/contact/tmpl/edit.php
@@ -22,9 +22,6 @@
<?php echo $this->form->getField('misc')->save(); ?>
Joomla.submitform(task, document.getElementById('contact-form'));
}
- else {
- alert('<?php echo $this->escape(JText::_('JGLOBAL_VALIDATION_FORM_FAILED'));?>');
- }
}
</script>
View
2  administrator/components/com_content/views/article/tmpl/edit.php
@@ -55,8 +55,6 @@
if (task == 'article.cancel' || document.formvalidator.isValid(document.id('item-form'))) {
<?php echo $this->form->getField('articletext')->save(); ?>
Joomla.submitform(task, document.getElementById('item-form'));
- } else {
- alert('<?php echo $this->escape(JText::_('JGLOBAL_VALIDATION_FORM_FAILED'));?>');
}
}
</script>
View
2  administrator/components/com_modules/views/module/tmpl/edit.php
@@ -31,8 +31,6 @@
if (self != top) {
window.top.setTimeout('window.parent.SqueezeBox.close()', 1000);
}
- } else {
- alert('".$this->escape(JText::_('JGLOBAL_VALIDATION_FORM_FAILED'))."');
}
}";
View
4 administrator/components/com_newsfeeds/views/newsfeed/tmpl/edit.php
@@ -21,8 +21,6 @@
{
if (task == 'newsfeed.cancel' || document.formvalidator.isValid(document.id('newsfeed-form'))) {
Joomla.submitform(task, document.getElementById('newsfeed-form'));
- } else {
- alert('<?php echo $this->escape(JText::_('JGLOBAL_VALIDATION_FORM_FAILED'));?>');
}
}
</script>
@@ -230,7 +228,7 @@
</div>
</div>
</fieldset>
- </div>
+ </div>
<!-- End Sidebar -->
</div>
</form>
View
2  administrator/components/com_templates/views/source/tmpl/edit.php
@@ -20,8 +20,6 @@
if (task == 'source.cancel' || document.formvalidator.isValid(document.id('source-form'))) {
<?php echo $this->form->getField('source')->save(); ?>
Joomla.submitform(task, document.getElementById('source-form'));
- } else {
- alert('<?php echo $this->escape(JText::_('JGLOBAL_VALIDATION_FORM_FAILED'));?>');
}
}
</script>
View
5 administrator/components/com_weblinks/views/weblink/tmpl/edit.php
@@ -22,9 +22,6 @@
<?php echo $this->form->getField('description')->save(); ?>
Joomla.submitform(task, document.getElementById('weblink-form'));
}
- else {
- alert('<?php echo $this->escape(JText::_('JGLOBAL_VALIDATION_FORM_FAILED'));?>');
- }
}
</script>
@@ -151,7 +148,7 @@
<?php echo JHtml::_('form.token'); ?>
</div>
</div>
- <!-- End Weblinks -->
+ <!-- End Weblinks -->
<!-- Begin Sidebar -->
<div class="span2">
<h4><?php echo JText::_('JDETAILS');?></h4>
View
1  administrator/language/en-GB/en-GB.lib_joomla.ini
@@ -282,6 +282,7 @@ JLIB_FORM_ERROR_FIELDS_GROUPEDLIST_ELEMENT_NAME="Unknown element type: %s"
JLIB_FORM_ERROR_NO_DATA="No data"
JLIB_FORM_ERROR_VALIDATE_FIELD="Invalid xml field"
JLIB_FORM_ERROR_XML_FILE_DID_NOT_LOAD="XML file did not load"
+JLIB_FORM_FIELD_INVALID="Invalid field:&#160";
JLIB_FORM_INVALID_FORM_OBJECT="Invalid Form Object: :%s"
JLIB_FORM_INVALID_FORM_RULE="Invalid Form Rule: :%s"
JLIB_FORM_MEDIA_PREVIEW_ALT="Selected image"
View
2  administrator/templates/hathor/html/com_categories/category/edit.php
@@ -26,8 +26,6 @@
if (task == 'category.cancel' || document.formvalidator.isValid(document.id('item-form'))) {
<?php echo $this->form->getField('description')->save(); ?>
Joomla.submitform(task, document.getElementById('item-form'));
- } else {
- alert('<?php echo $this->escape(JText::_('JGLOBAL_VALIDATION_FORM_FAILED'));?>');
}
}
</script>
View
3  administrator/templates/hathor/html/com_contact/contact/edit.php
@@ -21,9 +21,6 @@
<?php echo $this->form->getField('misc')->save(); ?>
Joomla.submitform(task, document.getElementById('contact-form'));
}
- else {
- alert('<?php echo $this->escape(JText::_('JGLOBAL_VALIDATION_FORM_FAILED'));?>');
- }
}
</script>
View
2  administrator/templates/hathor/html/com_content/article/edit.php
@@ -51,8 +51,6 @@
if (task == 'article.cancel' || document.formvalidator.isValid(document.id('item-form'))) {
<?php echo $this->form->getField('articletext')->save(); ?>
Joomla.submitform(task, document.getElementById('item-form'));
- } else {
- alert('<?php echo $this->escape(JText::_('JGLOBAL_VALIDATION_FORM_FAILED'));?>');
}
}
</script>
View
2  administrator/templates/hathor/html/com_modules/module/edit.php
@@ -25,8 +25,6 @@
if (self != top) {
window.top.setTimeout('window.parent.SqueezeBox.close()', 1000);
}
- } else {
- alert('".$this->escape(JText::_('JGLOBAL_VALIDATION_FORM_FAILED'))."');
}
}";
View
2  administrator/templates/hathor/html/com_newsfeeds/newsfeed/edit.php
@@ -21,8 +21,6 @@
{
if (task == 'newsfeed.cancel' || document.formvalidator.isValid(document.id('newsfeed-form'))) {
Joomla.submitform(task, document.getElementById('newsfeed-form'));
- } else {
- alert('<?php echo $this->escape(JText::_('JGLOBAL_VALIDATION_FORM_FAILED'));?>');
}
}
</script>
View
3  administrator/templates/hathor/html/com_weblinks/weblink/edit.php
@@ -20,9 +20,6 @@
<?php echo $this->form->getField('description')->save(); ?>
Joomla.submitform(task, document.getElementById('weblink-form'));
}
- else {
- alert('<?php echo $this->escape(JText::_('JGLOBAL_VALIDATION_FORM_FAILED'));?>');
- }
}
</script>
<div class="weblink-edit">
View
6 components/com_content/views/form/tmpl/edit.php
@@ -33,8 +33,6 @@
if (task == 'article.cancel' || document.formvalidator.isValid(document.id('adminForm'))) {
<?php echo $this->form->getField('articletext')->save(); ?>
Joomla.submitform(task);
- } else {
- alert('<?php echo $this->escape(JText::_('JGLOBAL_VALIDATION_FORM_FAILED')); ?>');
}
}
</script>
@@ -81,7 +79,7 @@
<?php echo $this->form->getInput('title'); ?>
</div>
</div>
-
+
<?php if (is_null($this->item->id)): ?>
<div class="control-group">
<div class="control-label">
@@ -320,7 +318,7 @@
<?php echo $this->form->getInput('metakey'); ?>
</div>
</div>
-
+
<input type="hidden" name="task" value="" />
<input type="hidden" name="return" value="<?php echo $this->return_page; ?>" />
<?php if($this->params->get('enable_category', 0) == 1) :?>
View
3  components/com_weblinks/views/form/tmpl/edit.php
@@ -23,9 +23,6 @@
<?php echo $this->form->getField('description')->save(); ?>
Joomla.submitform(task);
}
- else {
- alert('<?php echo $this->escape(JText::_('JGLOBAL_VALIDATION_FORM_FAILED'));?>');
- }
}
</script>
<div class="edit<?php echo $this->pageclass_sfx; ?>">
View
3  installation/CHANGELOG
@@ -26,6 +26,9 @@ $ -> Language fix or change
- -> Removed
! -> Note
+13-Nov-2012 Jean-Marie Simonet
+ #$ [#29669] Consistent form validation notifications. Thanks Roland
+
11-Nov-2012 Jean-Marie Simonet
# [#29569] *Implementing accordeons for Modules Options
# [#29635] * No message notification when new article is created
View
1  language/en-GB/en-GB.lib_joomla.ini
@@ -282,6 +282,7 @@ JLIB_FORM_ERROR_FIELDS_GROUPEDLIST_ELEMENT_NAME="Unknown element type: %s"
JLIB_FORM_ERROR_NO_DATA="No data"
JLIB_FORM_ERROR_VALIDATE_FIELD="Invalid xml field"
JLIB_FORM_ERROR_XML_FILE_DID_NOT_LOAD="XML file did not load"
+JLIB_FORM_FIELD_INVALID="Invalid field:&#160";
JLIB_FORM_INVALID_FORM_OBJECT="Invalid Form Object: :%s"
JLIB_FORM_INVALID_FORM_RULE="Invalid Form Rule: :%s"
JLIB_FORM_MEDIA_PREVIEW_ALT="Selected image"
View
3  libraries/joomla/html/behavior.php
@@ -117,6 +117,9 @@ public static function formvalidation()
return;
}
+ // Add validate.js language strings
+ JText::script('JLIB_FORM_FIELD_INVALID');
+
// Include MooTools framework
self::framework();
View
14 media/system/js/validate-uncompressed.js
@@ -158,6 +158,20 @@ var JFormValidator = new Class({
}
});
+ if (!valid) {
+ var message = Joomla.JText._('JLIB_FORM_FIELD_INVALID');
+ var errors = jQuery("label.invalid");
+ var error = new Object();
+ error.error = new Array();
+ for (var i=0;i < errors.length; i++) {
+ var label = jQuery(errors[i]).text();
+ if (label != 'undefined') {
+ error.error[i] = message+label.replace("*", "");
+ }
+ }
+ Joomla.renderMessages(error);
+ }
+
return valid;
},
View
8 media/system/js/validate.js
@@ -1,10 +1,4 @@
/*
GNU General Public License version 2 or later; see LICENSE.txt
*/
-Object.append(Browser.Features,{inputemail:function(){var a=document.createElement("input");a.setAttribute("type","email");return a.type!=="text"}()});
-var JFormValidator=new Class({initialize:function(){this.handlers={};this.custom={};this.setHandler("username",function(a){regex=/[<|>|"|'|%|;|(|)|&]/i;return!regex.test(a)});this.setHandler("password",function(a){regex=/^\S[\S ]{2,98}\S$/;return regex.test(a)});this.setHandler("numeric",function(a){regex=/^(\d|-)?(\d|,)*\.?\d*$/;return regex.test(a)});this.setHandler("email",function(a){regex=/^[a-zA-Z0-9._-]+(\+[a-zA-Z0-9._-]+)*@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;return regex.test(a)});$$("form.form-validate").each(function(a){this.attachToForm(a)},
-this)},setHandler:function(a,b,c){this.handlers[a]={enabled:c==""?!0:c,exec:b}},attachToForm:function(a){a.getElements("input,textarea,select,button").each(function(a){a.hasClass("required")&&(a.set("aria-required","true"),a.set("required","required"));if((document.id(a).get("tag")=="input"||document.id(a).get("tag")=="button")&&document.id(a).get("type")=="submit"){if(a.hasClass("validate"))a.onclick=function(){return document.formvalidator.isValid(this.form)}}else if(a.addEvent("blur",function(){return document.formvalidator.validate(this)}),
-a.hasClass("validate-email")&&Browser.Features.inputemail)a.type="email"})},validate:function(a){a=document.id(a);if(a.get("disabled"))return this.handleResponse(!0,a),!0;if(a.hasClass("required"))if(a.get("tag")=="fieldset"&&(a.hasClass("radio")||a.hasClass("checkboxes")))for(var b=0;;b++)if(document.id(a.get("id")+b)){if(document.id(a.get("id")+b).checked)break}else return this.handleResponse(!1,a),!1;else if(!a.get("value"))return this.handleResponse(!1,a),!1;b=a.className&&a.className.search(/validate-([a-zA-Z0-9\_\-]+)/)!=
--1?a.className.match(/validate-([a-zA-Z0-9\_\-]+)/)[1]:"";if(b=="")return this.handleResponse(!0,a),!0;if(b&&b!="none"&&this.handlers[b]&&a.get("value")&&this.handlers[b].exec(a.get("value"))!=!0)return this.handleResponse(!1,a),!1;this.handleResponse(!0,a);return!0},isValid:function(a){for(var b=!0,a=a.getElements("fieldset").concat(Array.from(a.elements)),c=0;c<a.length;c++)this.validate(a[c])==!1&&(b=!1);(new Hash(this.custom)).each(function(a){a.exec()!=!0&&(b=!1)});return b},handleResponse:function(a,
-b){b.labelref||$$("label").each(function(a){if(a.get("for")==b.get("id"))b.labelref=a});a==!1?(b.addClass("invalid"),b.set("aria-invalid","true"),b.labelref&&(document.id(b.labelref).addClass("invalid"),document.id(b.labelref).set("aria-invalid","true"))):(b.removeClass("invalid"),b.set("aria-invalid","false"),b.labelref&&(document.id(b.labelref).removeClass("invalid"),document.id(b.labelref).set("aria-invalid","false")))}});document.formvalidator=null;
-window.addEvent("domready",function(){document.formvalidator=new JFormValidator});
+Object.append(Browser.Features,{inputemail:function(){var e=document.createElement("input");e.setAttribute("type","email");return e.type!=="text"}()});var JFormValidator=new Class({initialize:function(){this.handlers=Object();this.custom=Object();this.setHandler("username",function(e){regex=new RegExp("[<|>|\"|'|%|;|(|)|&]","i");return!regex.test(e)});this.setHandler("password",function(e){regex=/^\S[\S ]{2,98}\S$/;return regex.test(e)});this.setHandler("numeric",function(e){regex=/^(\d|-)?(\d|,)*\.?\d*$/;return regex.test(e)});this.setHandler("email",function(e){regex=/^[a-zA-Z0-9._-]+(\+[a-zA-Z0-9._-]+)*@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;return regex.test(e)});var e=$$("form.form-validate");e.each(function(e){this.attachToForm(e)},this)},setHandler:function(e,t,n){n=n==""?true:n;this.handlers[e]={enabled:n,exec:t}},attachToForm:function(e){e.getElements("input,textarea,select,button").each(function(e){if(e.hasClass("required")){e.set("aria-required","true");e.set("required","required")}if((document.id(e).get("tag")=="input"||document.id(e).get("tag")=="button")&&document.id(e).get("type")=="submit"){if(e.hasClass("validate")){e.onclick=function(){return document.formvalidator.isValid(this.form)}}}else{e.addEvent("blur",function(){return document.formvalidator.validate(this)});if(e.hasClass("validate-email")&&Browser.Features.inputemail){e.type="email"}}})},validate:function(e){e=document.id(e);if(e.get("disabled")){this.handleResponse(true,e);return true}if(e.hasClass("required")){if(e.get("tag")=="fieldset"&&(e.hasClass("radio")||e.hasClass("checkboxes"))){for(var t=0;;t++){if(document.id(e.get("id")+t)){if(document.id(e.get("id")+t).checked){break}}else{this.handleResponse(false,e);return false}}}else if(!e.get("value")){this.handleResponse(false,e);return false}}var n=e.className&&e.className.search(/validate-([a-zA-Z0-9\_\-]+)/)!=-1?e.className.match(/validate-([a-zA-Z0-9\_\-]+)/)[1]:"";if(n==""){this.handleResponse(true,e);return true}if(n&&n!="none"&&this.handlers[n]&&e.get("value")){if(this.handlers[n].exec(e.get("value"))!=true){this.handleResponse(false,e);return false}}this.handleResponse(true,e);return true},isValid:function(e){var t=true;var n=e.getElements("fieldset").concat(Array.from(e.elements));for(var r=0;r<n.length;r++){if(this.validate(n[r])==false){t=false}}(new Hash(this.custom)).each(function(e){if(e.exec()!=true){t=false}});if(!t){var i=Joomla.JText._("JLIB_FORM_FIELD_INVALID");var s=jQuery("label.invalid");var o=new Object;o.error=new Array;for(var r=0;r<s.length;r++){var u=jQuery(s[r]).text();if(u!="undefined"){o.error[r]=i+u.replace("*","")}}Joomla.renderMessages(o)}return t},handleResponse:function(e,t){if(!t.labelref){var n=$$("label");n.each(function(e){if(e.get("for")==t.get("id")){t.labelref=e}})}if(e==false){t.addClass("invalid");t.set("aria-invalid","true");if(t.labelref){document.id(t.labelref).addClass("invalid");document.id(t.labelref).set("aria-invalid","true")}}else{t.removeClass("invalid");t.set("aria-invalid","false");if(t.labelref){document.id(t.labelref).removeClass("invalid");document.id(t.labelref).set("aria-invalid","false")}}}});document.formvalidator=null;window.addEvent("domready",function(){document.formvalidator=new JFormValidator})
View
3  templates/beez3/html/com_weblinks/form/edit.php
@@ -23,9 +23,6 @@
<?php echo $this->form->getField('description')->save(); ?>
Joomla.submitform(task);
}
- else {
- alert('<?php echo $this->escape(JText::_('JGLOBAL_VALIDATION_FORM_FAILED'));?>');
- }
}
</script>
<div class="edit<?php echo $this->pageclass_sfx; ?>">
Please sign in to comment.
Something went wrong with that request. Please try again.