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

$(document).ready(function() {

    $('.action-button').on('click', function() {
        console.log('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');

            //alert('Email not valid');
            alert('email not valid');
            $('.email-address input').val('');
            $('.email-address input').attr("placeholder", "Please enter valid student email address");

            if ($('.pw-validation').length) {
                alert('.pw-already exists');
            } else {
                $('.email-address input').after("<div class='pw-validation'>It seems the email address entered doesn’t match our records. Please try again or if you don’t have a school email address, <a href='https://play-wave.myshopify.com/pages/new-member'>click here</a> or email us at <a href='mailto:[email protected]'>[email protected]</a> to verify your age. You will need to submit / email a photo or scan of a form of ID with your birth date on it (You can upload a photo of your Passport, NSW ID card, drivers licence, concession card, etc.)</div>");
            }

        } else {
            alert(matches_array + ' allowed');
        }
    });
});