From 90a576f86f49aa0aa4ff41fcc874288126e9de45 Mon Sep 17 00:00:00 2001 From: Jeff Godin Date: Mon, 22 Jun 2015 15:21:09 -0400 Subject: [PATCH] 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 --- Open-ILS/web/js/ui/default/actor/user/register.js | 6 ++++++ 1 file changed, 6 insertions(+) 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; -- 2.11.0