[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

HTML Form is submitting despite return false in onclick while using Internet Explorer

Posted on 2008-09-30
5
Medium Priority
?
537 Views
Last Modified: 2012-05-05
Below is a code that works perfectly in firefox but not in internet explorer. In internet explorer, if you press enter without hitting the button, it submits the form instead of calling the ajax. The problem is that for some reason internet explorer doesn't recognize return false I think.

Again, this works 100% in firefox whether you click the button, or press enter.But in IE only clicking the button makes the form function correctly.

Live URL: http://www.urgentpropertysale.com/form/ups/property_form_1.php?source_2=UPS%20OnlineForm

You can test using this form if you wish.
<form id="form" name="property_form" method="post" action="property_form_save.php">
  <div id="property_div">
  <table width="100%" cellspacing="0" cellpadding="3">
    <tr>
      <td><strong>Enter your Postcode to get started now and receive your FREE Valuation &amp; FREE Books: </strong></td>
    </tr>
    <tr>
      <td><p>
        <input type="text" name="post_code" value="<?=$_REQUEST[post_code]?>"/> 
          <input type="submit" name="Submit2" value="Search Postcode" onclick="
		var postvars = gather('property_form');
		callAJAX('property_form_address_retrieve.php','property_div',postvars); 
		return false;"/>
          </p>
        </td>
    </tr>
  </table>  </div>
  </form>

Open in new window

0
Comment
Question by:MeridianManagement
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 82

Expert Comment

by:hielo
ID: 22605259
try:
<form id="form" name="property_form" method="post" action="property_form_save.php"  onsubmit="var postvars = gather('property_form');callAJAX('property_form_address_retrieve.php','property_div',postvars); return false;">
  <div id="property_div">
  <table width="100%" cellspacing="0" cellpadding="3">
    <tr>
      <td><strong>Enter your Postcode to get started now and receive your FREE Valuation & FREE Books: </strong></td>
    </tr>
    <tr>
      <td><p>
        <input type="text" name="post_code" value="<?=$_REQUEST[post_code]?>"/> 
          <input type="submit" name="Submit2" value="Search Postcode" />
          </p>
        </td>
    </tr>
  </table>  </div>
  </form>

Open in new window

0
 
LVL 44

Accepted Solution

by:
scrathcyboy earned 2000 total points
ID: 22610420
Here is the general way to stop ENTER from submitting a form --

document.onkeypress = keyPress;
var count = 1;
function keyPress() {
if (window.event.keyCode == 13)
{
    event.returnValue=false;
    event.cancel = true;
}
}

also see this link for onKeyDown --

http://www.thefutureoftheweb.com/blog/submit-a-form-in-ie-with-enter
0
 
LVL 2

Author Comment

by:MeridianManagement
ID: 22614786
That will work for the first leg, but then it never actually submits to property_form_save.php, am I right?
0
 
LVL 2

Author Comment

by:MeridianManagement
ID: 22614792
scrathcyboy, didn't see your solution I was speaking to hielo, I'll try it.
0
 
LVL 82

Expert Comment

by:hielo
ID: 22615081
>>That will work for the first leg,
???
It doesn't allow you submit the form via enter or clicking the submit button. IF you wanted to submit the form you would need to do:
document.property_form.submit();
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question