Browse Source

DIV-1142: Check that it's a valid email address

pull/170/head
ariannedee 5 years ago
parent
commit
74166ad912
3 changed files with 12 additions and 6 deletions
  1. +7
    -3
      edivorce/apps/core/static/js/functions.js
  2. +4
    -2
      edivorce/apps/core/static/js/signing-filing.js
  3. +1
    -1
      edivorce/apps/core/templates/dashboard/sign_file_options.html

+ 7
- 3
edivorce/apps/core/static/js/functions.js View File

@ -337,6 +337,12 @@ var getValue = function(el, question){
} }
}; };
var isEmailValid = function(el) {
var value = el.val();
var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
return regex.test(value);
}
// check if email is in valid format // check if email is in valid format
var validateEmail = function(el){ var validateEmail = function(el){
@ -345,9 +351,7 @@ var validateEmail = function(el){
.find('span.help-block') .find('span.help-block')
.remove(); .remove();
var value = el.val();
var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (regex.test(value)) {
if (isEmailValid(el)) {
return true; return true;
} else { } else {
el.closest('.form-group') el.closest('.form-group')


+ 4
- 2
edivorce/apps/core/static/js/signing-filing.js View File

@ -98,13 +98,15 @@ $(window).load(function () {
$('#check-email-filled').on('click', function (e) { $('#check-email-filled').on('click', function (e) {
var yourEmailInput = $('#email-you-input'); var yourEmailInput = $('#email-you-input');
var yourEmailError = yourEmailInput.is(":visible") && !yourEmailInput.val();
var yourEmailError = yourEmailInput.is(":visible") && !(yourEmailInput.val() && isEmailValid(yourEmailInput));
var spouseEmailInput = $('#email-spouse-input'); var spouseEmailInput = $('#email-spouse-input');
var spouseEmailError = spouseEmailInput.is(":visible") && !spouseEmailInput.val();
var spouseEmailError = spouseEmailInput.is(":visible") && !(spouseEmailInput.val() && isEmailValid(spouseEmailInput));
if (yourEmailError || spouseEmailError) { if (yourEmailError || spouseEmailError) {
$('#unfilled-email-alert').show(); $('#unfilled-email-alert').show();
$('#error-email-you').toggle(yourEmailError) $('#error-email-you').toggle(yourEmailError)
$('#error-email-spouse').toggle(spouseEmailError) $('#error-email-spouse').toggle(spouseEmailError)
yourEmailInput.toggleClass('error', yourEmailError);
spouseEmailInput.toggleClass('error', spouseEmailError);
e.preventDefault(); e.preventDefault();
} else { } else {
$('#unfilled-email-alert').hide(); $('#unfilled-email-alert').hide();


+ 1
- 1
edivorce/apps/core/templates/dashboard/sign_file_options.html View File

@ -149,7 +149,7 @@
<div class="information-message bg-danger add-top-margin" id="unfilled-email-alert" hidden> <div class="information-message bg-danger add-top-margin" id="unfilled-email-alert" hidden>
<p> <p>
You must fill in the following field(s) before you can continue:
You must provide a valid email for the following field(s) before you can continue:
</p> </p>
<ul> <ul>
<li id="error-email-you">E-mail Address for You</li> <li id="error-email-you">E-mail Address for You</li>


Loading…
Cancel
Save