diff --git a/copanier/static/js/app.js b/copanier/static/js/app.js new file mode 100644 index 0000000..228e2c7 --- /dev/null +++ b/copanier/static/js/app.js @@ -0,0 +1,15 @@ +/* Handle nice phone number formatting */ +function prettifyPhoneNumber(selector) { + input = document.getElementById(selector) + var phone = input.value; + + phone = phone.replace(/[^0-9]/g, '') // Only keep digits. + phone = (function addSpaces(phone) { + if (phone.length <= 2) { + return phone + } + return phone.substring(0, 2) + ' ' + addSpaces(phone.substring(2)) + }(phone)) + + input.value = phone; +} diff --git a/copanier/templates/base.html b/copanier/templates/base.html index 542d6a6..888d692 100644 --- a/copanier/templates/base.html +++ b/copanier/templates/base.html @@ -61,6 +61,7 @@ + {% if message %}