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=0004aad44e14d9855170f49f4093cfcd54100732;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 a82da9f86f..3012e10448 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;