Link to home
Start Free TrialLog in
Avatar of MeridianManagement
MeridianManagementFlag for United States of America

asked on

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

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

Avatar of hielo
hielo
Flag of Wallis and Futuna image

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

ASKER CERTIFIED SOLUTION
Avatar of scrathcyboy
scrathcyboy
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MeridianManagement

ASKER

That will work for the first leg, but then it never actually submits to property_form_save.php, am I right?
scrathcyboy, didn't see your solution I was speaking to hielo, I'll try it.
>>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();