Created
September 12, 2016 10:31
-
-
Save misterbailey/b31635f8735b03ef26aeacaf1abe0cca to your computer and use it in GitHub Desktop.
Used for forms on the Student Ideas submission form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$( document ).ready(function() { | |
// Delcare Vars | |
var email = $('input#email'); | |
var emailWrap = $('.email-wrap'); | |
var emailWrapperAlert = email.parent('.input-wrap > div.alert'); | |
var alertBox = true; | |
var emailVal = $('input#email').val() | |
$('#ideas-submit-button').click(function(event){ | |
// Stop the button default | |
event.preventDefault(); | |
// Check if uwe.ac.uk email is being used | |
if ( emailVal.indexOf('@uwe.ac.uk') >= 0 ) { | |
console.log('uwe email used'); | |
} else { | |
console.log('uwe email was not used'); | |
if (alertBox) { | |
console.log(alertBox); | |
emailWrap.append('<div id="emailError" class="alert alert-danger"><strong>Please use a @uwe.ac.uk email</strong></div>'); | |
alertBox = false; | |
console.log(alertBox); | |
} else { | |
console.log('already an alert present'); | |
console.log(alertBox); | |
$('#emailError').css('background-color', '#fff').delay(500).queue(function (next) { $(this).css('background-color', '#f2dede');next(); }); | |
} | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment