JSFiddle - React, Tailwind, and code Playground
by m4xout
HTML
<input type="text" id="customr21" name="customer[school_email]" class="customr-control" autocomplete="off">
<input type="submit" class="btn btn-primary button action-button" value="Create Account">
JavaScript
$('.action-button').on('click', function(){
alert('button clicked');
var email_string = $('input#customr21').val();
var regexp = /[^\s]*edu.au/g;
var matches_array = email_string.match(regexp);
if (matches_array === undefined || matches_array === null) {
// do something
alert(matches_array + ' undefined or null');
console.log('email not valid');
$('input#customr21').val('');
$('input#customr21').attr("placeholder", "Please enter valid student email address");
} else {
alert(matches_array + ' allowed');
}
});