Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

86
Views
Form is submitted even invalid email address - JQuery

I have below code and currently it bypasses the 'return false' expression when i enter incorrect format of email address. Any idea please.

index.html

<form class="text-muted first" 
      action="javascript:;" 
      method="POST"
      id="contactform" 
      name="form1" 
      onsubmit="ajaxRequest(); return false">
    <div class="form-group">
        <label for="name">Name</label>
        <input type="text" class="form-control" id="name" name="name" 
            required placeholder="Ahmed">
    </div>
    <div class="form-group">
        <label for="email" class="mt-2">Email</label>
        <input type="text" class="form-control" id="email" name="emailaddr" 
            required placeholder="john@email.com">
    </div>
    <button class="btn btn-outline-warning p-2 mt-2" type="submit" 
        onclick="ValidateEmail(document.form1.emailaddr)">Submit Question</button>
</form>

JavaScript

$(document).ready(function() {
    $('.nav-button').click(function() {
        $('.nav-button').toggleClass('change');
    });

    $(window).scroll(function() {
        let position = $(this).scrollTop();
        if (position >= 200) {
            $('.nav-menu').addClass('custom-navbar');
        } else {
            $('.nav-menu').removeClass('custom-navbar');
        }
    });
});

function ValidateEmail(inputText) {
    var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
    if (inputText.value.match(mailformat)) {
        alert('Email Sent!');
        return true;
    } else {
        return false;
    }
}

function ajaxRequest(e) {
    $.get('mail.php', function(data) {
        // $(".result").html(data);
        // alert("Load was performed.");
        $('.contactform').hide();
        $('.confirmation').show();
    });
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!