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 8650553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:51:02+00:00 2026-06-12T13:51:02+00:00

I have a form like: <form method=POST action=page.html onsubmit=alert(‘foo’); // validate(); name=foobar> … </form>

  • 0

I have a form like:

<form method="POST" action="page.html" onsubmit="alert('foo'); // validate();" name="foobar">
...
</form>

and a link like:

<div onclick="document.foobar.submit();">click me</div>

How can I capture the submit() method and call my validate function?

JsBin example

  • 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-06-12T13:51:03+00:00Added an answer on June 12, 2026 at 1:51 pm

    You can call method from html itself. modified jsbin. Instead of submitting form on click you can call submitHandler and pass form reference.

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset=utf-8 />
    <title>JS Bin</title>
      <script type="text/javascript">
        function validate(){
    
        }
    
        function submitHandler(form){
          validate();
          alert('foo');
    
    }
        window.onload = function(){
            document.foobar.submit = submitHandler;
        }
    </script>
    
    </head>
    <body>
        <form method="POST" action="page.html" onsubmit="submitHandler(this);" name="foobar">
          <input type="text" />
        </form>
    
        <div onclick="document.foobar.submit()">click me</div>
    </body>    
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form like this: <form id=loginCompact action=https://externalsite... name=sportsbook method=post onsubmit=createCookie('BRLOG', document.sportsbook.username.value, 1)>
I have a html file like following: <form action=/2811457/follow?gsid=3_5bce9b871484d3af90c89f37 method=post> <div> <a href=/2811457/follow?page=2&amp;gsid=3_5bce9b871484d3af90c89f37>next_page</a> &nbsp;<input
I have a simple form like this: <form name=serachForm method=post action=/home/search> <input type=text name=searchText
I have a simple form like this : <form method=post name=change_pass id=change_pass action=change_pass2.php> <input
I have a form that looks like this. <form action=index.php method=post> <select name=dropdownOption> <option
I have code that looks like the following: <form id=MyForm name=MyForm method=post action=index.php> <input
I have form like this: <form method=POST action=<?php echo base_url() ?>admin/admin_search> <fieldset> <label for=nalozi>Nalozi</label><input
I have a form like this: <form action=form_send.php method=post> <table> <tr> <td><label for=address>address</label></td> <td><input
I have a form like this: <form id=surveyForm method=post action=submit.php> <input type=text id=good value=0
I have been given some generated code which looks like so: <form id=form1 method=post

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.