From: Jeff Godin Date: Mon, 22 Jun 2015 19:21:09 +0000 (-0400) Subject: Enforce valid phone numbers in user settings X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=90a576f86f49aa0aa4ff41fcc874288126e9de45;p=evergreen%2Ftadl.git Enforce valid phone numbers in user settings Enforce valid phone numbers in user settings by preventing a save of the user if the widgets are not considered isValid. Also, since the staff client doesn't seem to style yellow when we're asking it to, use an alert() for invalid data. Signed-off-by: Jeff Godin --- diff --git a/Open-ILS/web/js/ui/default/actor/user/register.js b/Open-ILS/web/js/ui/default/actor/user/register.js index 649d0bbfe2..a88ef42344 100644 --- a/Open-ILS/web/js/ui/default/actor/user/register.js +++ b/Open-ILS/web/js/ui/default/actor/user/register.js @@ -991,6 +991,11 @@ function uEditDrawSettingRow(tbody, dividerRow, template, stype) { case 'opac.default_phone': var tb = new dijit.form.TextBox({scrollOnFocus:false}, getByName(row, 'widget')); tb.attr('value', userSettings[stype.name()]); + tb.isValid = function() { + if (this.value.match(/^\s*$/) || this.value.match(/^\d{3}-\d{3}-\d{4}$/)) { + return true; + } + }; if (stype.name() === 'opac.default_sms_notify') { dojo.create("div", {innerHTML: ""}, row); } @@ -1016,6 +1021,7 @@ function uEditDrawSettingRow(tbody, dividerRow, template, stype) { } } else { dojo.style(tb.domNode, "background-color", "yellow"); + alert("Invalid value for " + stype.label()); } userSettingsToUpdate[stype.name()] = newVal; }); break;