Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 556659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:56:35+00:00 2026-05-13T11:56:35+00:00

My JavaScript function is working but for some reason after the alert is displayed

  • 0

My JavaScript function is working but for some reason after the alert is displayed inside my IF statement the page re-loads/refresh and I do not want it to. Why is this and how can I change my function so that it will not do this?

My function

function valSubmit(){    
    varName = document.form1.txtName.value;
    varSurname = document.form1.txtSurname.value;
    varEmail = document.form1.txtEmail.value;
    varOrg = document.form1.txtOrg.value;

    if (varName == "" || varSurname == "" || varEmail == "" || varOrg == "" ) 
    {

     alert("Please fill in all mandatory fields");  

    }
    else
    { 
        document.body.style.cursor = 'wait';
        document.form1.btnSubmit.style.cursor = 'wait';
        document.form1.action = "http://now.eloqua.com/e/f2.aspx"
        document.form1.submit();
        return true;    
    }

 }

p.s I am using ASP.NET 3.5

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T11:56:36+00:00Added an answer on May 13, 2026 at 11:56 am

    Here is your complete function with the return false statement added.

    Additionally, when you call valSubmit, it should look like this:

    … onsubmit=”return valSubmit();”…

    Note, you need to specify return here also.

    Here is the function:

    function valSubmit(){
    
    varName = document.form1.txtName.value;
    varSurname = document.form1.txtSurname.value;
    varEmail = document.form1.txtEmail.value;
    varOrg = document.form1.txtOrg.value;
    
     if (varName == "" || varSurname == "" || varEmail == "" || varOrg == "" ) 
     {
    
         alert("Please fill in all mandatory fields");
         return false;
    
     }
     else
     { 
        document.body.style.cursor = 'wait';
        document.form1.btnSubmit.style.cursor = 'wait';
        document.form1.action = "http://now.eloqua.com/e/f2.aspx"
        document.form1.submit();
        return true;    
     }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Window.open javascript function is not working in Mozilla, but working in other browsers, here
.load() was working fine, but for some reason it's not in Chrome now (presumably
I have a javascript function, that works fine if it's anonymous but stops working
can someone explain me why this script is not working? <script type=text/javascript> function destroy(ID)
The page I am working on has a javascript function executed to print parts
I've got a jsFiddle working how I want: http://jsfiddle.net/6wuUc/64/ But for some reason, when
So I had this working perfectly fine, but now for some reason I can't
I have this function working <script type=text/javascript> $(window).scroll(function() { if ($(window).scrollTop() == $(document).height() -
I tried to write a function to check key code with JavaScript. It's working
For some reason my simple jquery bind event isn't working. The funny thing is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.