$(document).ready(function(){ $('.footer-sign-up input[type=button]').click(function(){ var email = $('.footer-sign-up input[type=text]').val(); var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; if(!regex.test(email)) { $('.footer-sign-up input[type=text]').addClass('error'); $(".newslettererror").show(); return false; } else { $(".newslettererror").hide(); } $.ajax({ url: "http://www.cambridgesatchel.com/on/demandware.store/Sites-csc_gb-Site/en_GB/Sailthru-SendEmailSignupDetails", type: 'post', data: JSON.stringify( { email:email } ), success: function (data) { //console.info(data); $('.footer-sign-up input[type=text]').removeClass('error'); $('.footer-sign-up input[type=text]').val(''); $( "
Thank you for signing up to our newsletter!
" ).dialog({ modal: true, height: 100, width: 400 }); } }); }); });