I try to check if an email exists before allowing to submit the form.
if the email exists, I get the alert which I added to test the form, but it still submits the form and moves to "login.asp". I also added "event.preventDefault();" to try and stop it, but still it happens Here is my code:
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <script src="https://code.jquery.com/jquery-latest.js"></script>
    <script type="text/javascript">
        $(document).ready(function() { //newly added 
            $('#Submit').click(function() {
                alert('in');
                var emailVal = $('#email').val(); // assuming this is a input text field
                $.post('User_RegisterCheck.asp', {
                    'email': emailVal
                }, function(data) {
                    if (data == 'exist') {
                        alert('exits');
                        return false;
                        event.preventDefault();
                    } else $('#FormRegID').submit();
                });
            });
        });
    </script>
</head>
<body>
    <form method="post" id="FormRegID" name="FormRegID" action="login.asp">
        <div class="form-group ">
            <label for="email" class="control-label">email</label>
            <input type="email" class="form-control w-75" id="email" name="email" placeholder="email" required>
        </div>
        <input type="image" name="Submit" src="/images/button_login-register.png" border="0" alt="Submit" id="Submit" style="width: 209px;" />
        </div>
    </form>
</body>
</html>
How can I validate the email?
 
     
    