Skip to content

Commit

Permalink
Merge pull request #835 from mfb/client-side-email-validation
Browse files Browse the repository at this point in the history
Client-side email validation for congress messages
  • Loading branch information
alexymik authored Jun 3, 2020
2 parents 866b556 + 2ae87c8 commit 50ac99b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/assets/javascripts/application/tools/congress_message.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ $(document).on("ready", function() {
});

$("#congress-message-tool").on("click", "#to-page-3", function(){
// Run browser email validation, plus additional check for valid hostname.
if (!$('#common_attributes__EMAIL')[0].checkValidity() || !/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i.test($('#common_attributes__EMAIL').val())) {
show_error('Please double-check your email address and try again.', $('.rep-info'));
$(window).scrollTop($('.rep-info').offset().top);
return;
}
$(".rep-info").hide();
$("#customize-message").show();
if ($("#action-content").length) {
Expand Down

0 comments on commit 50ac99b

Please sign in to comment.