r82528 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82527‎ | r82528 | r82529 >
Date:19:03, 20 February 2011
Author:yaron
Status:deferred
Tags:
Comment:
Improved validation of number types to handle scientific/"E" notation, using patch from talk page
Modified paths:
  • /trunk/extensions/SemanticForms/libs/SemanticForms.js (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/libs/SemanticForms.js
@@ -489,7 +489,10 @@
490490
491491 jQuery.fn.validateNumberField = function() {
492492 var fieldVal = this.find("input").val();
493 - if (fieldVal == '' || fieldVal.match(/^\s*\-?[\d\.,]+\s*$/)) {
 493+ // Handle "E notation"/scientific notation ("1.2e-3") in addition
 494+ // to regular numbers
 495+ if (fieldVal == '' ||
 496+ fieldVal.match(/^\s*[\-+]?((\d+[\.,]?\d*)|(\d*[\.,]?\d+))([eE]?[\-\+]?\d+)?\s*$/)) {
494497 return true;
495498 } else {
496499 this.addErrorMessage(sfgBadNumberErrorStr);