Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Error when changing from button to image button...

Guest
Jul 23, 2009 Jul 23, 2009

Dear friends :

I have a form and a javascript to control the inputs after clicking the "submit" button :

This javascript verifies that some conditions must accomplish when one of the checkboxes is checked, for example. It works perfect when I use the typical submit button: it verifies the checkbox, and tells you to fill a text field when you forgot it... however, as soon as I change the tag of the button in order to customize it with an image, it fails : it does display the javascript verification, does remind you to fill the text field, BUT then it reloads the page and unchecks all the values that already are filled by user...   any explanation ?

This is my typical button:

<input name="button" type="button" onclick="Validar(this.form)" value="Continue" />

This is my image button:

<input type="image" src="img/btn_continue.png" onclick="Validar(this.form)"  width="101" height="22"/>

It is the same !!  why does it fail ?? thanks in advance for your answers...

TOPICS
Server side applications
649
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 24, 2009 Jul 24, 2009

It is the same !!  why does it fail ?? thanks in advance for your answers...

No, it's not the same. A form button automatically submits the form if the validation script returns true. An image simply executes the validation script. When you use an image, the validation script needs to submit the form as well.

Using image buttons for forms is generally not a good idea because the form cannot be submitted if JavaScript is disabled.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 24, 2009 Jul 24, 2009

thanks for the reply David, definetly you KNOW

Well.. anyway.. I need to customize my button... what would you suggest ? Thanks in advance,

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 24, 2009 Jul 24, 2009
LATEST

Googling around I found this... thanks a lot,

http://www.webreference.com/programming/css_stylish/

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines