Products.Archetypes/master: Fix bug with old jquery version and the possibility to add t
Valtteri Karppinen <jenkins-z4DKO/[email protected]>
| Newsgroups | gmane.comp.web.zope.plone.cvs |
|---|---|
| Message-ID | <[email protected]> |
Repository: Products.Archetypes Branch: refs/heads/master Date: 2017-07-04T12:25:22+03:00 Author: Valtteri Karppinen (vkarppinen) <[email protected]> Commit: https://github.com/plone/Products.Archetypes/commit/7aeea6c024e101b7c2a3be343b267d78634b5c4b Fix bug with old jquery version and the possibility to add text over max limit Files changed: M CHANGES.rst M Products/Archetypes/skins/archetypes/widgets/js/textcount.js diff --git a/CHANGES.rst b/CHANGES.rst index 4f95beed..bbe93737 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -14,7 +14,12 @@ New features: Bug fixes: -- *add item here* +- Fixed textcount.js support jquery>1.6. + [vkarppinen] + +- Fixed a bug (that it was possible to enter text length over maxlimit) + by replacing maxlimit alert() with highlighting textcountfield. + [vkarppinen] 1.14.1 (2017-06-16) diff --git a/Products/Archetypes/skins/archetypes/widgets/js/textcount.js b/Products/Archetypes/skins/archetypes/widgets/js/textcount.js index 48c9a85f..cd923e3e 100644 --- a/Products/Archetypes/skins/archetypes/widgets/js/textcount.js +++ b/Products/Archetypes/skins/archetypes/widgets/js/textcount.js @@ -1,12 +1,13 @@ <!-- Original: Ronnie T. Moore --> <!-- Dynamic 'fix' by: Nannette Thacker --> function textCounter(field, countfield, maxlimit) { - var fieldval = jQuery(field).attr('value'); + var fieldval = jQuery(field).val(); + var countfield = jQuery('input[name="' + countfield + '"]'); if (fieldval.length > maxlimit) { // if too long...trim it! - jQuery(field).attr('value', fieldval.substring(0, maxlimit)); - alert( 'This field is limited to ' + maxlimit + ' characters in length.' ); - } - // update 'characters left' counter - jQuery('input[name="' + countfield + '"]').attr('value', Math.max(maxlimit - fieldval.length, 0)); + jQuery(field).val(fieldval.substring(0, maxlimit)); + countfield.css('border', '1px solid red'); + } + // update 'characters left' counter + countfield.attr('value', Math.max(maxlimit - fieldval.length, 0)); } ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot