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

  • Home
  • SEARCH
  • 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 6986451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:48:37+00:00 2026-05-27T18:48:37+00:00

//HTML Code <div id=navigation1> <ul> <li><a href=#><input type=submit value=Next onClick=return checkfhname() /></a></li> </ul> </div>

  • 0
//HTML Code
<div id="navigation1">
<ul>
<li><a href="#"><input type="submit" value="Next" 
       onClick="return checkfhname()" /></a></li>
</ul>
</div>

My Javascript checkfhname() is returning false, at same time <li> tag navigating to next tab form, so I want to stop this navigation if Javascript returns false.

  • 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-27T18:48:38+00:00Added an answer on May 27, 2026 at 6:48 pm

    Explanation

    Hmm, your question is a bit… for the lack of a better word, “iffy”. However, I understand what you want to do.

    First of all, there is no need to put an input element inside the link when the link also responds to true/false. Second of all, you should NEVER put an input element inside a link.
    It’s just bad practice.

    When you return false via Javascript to a link, the link will not navigate you further, just like the input element wont send you further when you return false from a submit.

    This should suffice

    <a href="#" onClick="return checkfhname()">Next</a>
    

    If you’d rather want a button, just change it to a button, add a parameter for url, and use window.location = url if you want it to navigate

    <script>
        function checkNavigate(url){
            //check some conditions, conditions = false/true
            if(typeof url == "undefined" || !conditions) 
                return false;
    
            window.location = url;
            return true;
        }
    </script>
    <button onClick="checkNavigate('url')">Next</button>
    

    Solution

    Here’s a JSFiddle example.

    HTML

    <div id="navigation">
        <ul>
            <li>
                <a href="#link_clicked" onClick='return checkfhName();'>Link</a>
            </li>
        </ul>
    </div>
    

    Javascript

    function checkfhName(){
        //check your conditions, conditions = false/true
        //for the purposes of this example: conditions = false
        checkConditions = false;
        if(checkConditions){
            return true;
        }
        return false;
    }
    

    Additional information; good to know

    • Here’s a great article about what you should do instead of return false;
    • Some documentation on form validation
    • Here’s a similar question
    • Here’s another question, asking about the reason for return
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following html code: <div id='x'><div id='y'>Y content</div>X content</div> I'd like to extract
I have this HTML code: <div class='com_box'> <div class='com_box_c'> <div class='com_box_info'> <a id='quote'>quote</a> </div>
I have HTML code like this : <div> <a>Link A1</a> <a>Link A2</a> <a>Link A3</a>
I have html code that looks roughly like this: <div id=id1> <div id=id2> <p>some
I have the following html code (in the given order) <div id=content>...</div> <div id=footer>...</div>
I have the following html code. <html> <body> <div style=max-width:1600px; min-width:900px; > <table> </table>
I have the following HTML code based on a tab menu format, i.e: <div
I have the following html code: <table> <tr> <td> <div id=fixmywidth style=position:relative; height:30px;> <div
What am I doing wrong in this HTML code: <html> <head> </head> <body> <div
my CSS code .child{ width:100px; height:100px; display:inline-block; } my HTML code <div id=parent> <div

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.