Javascript Form How to - Use Image as the submit button








Question

We would like to know how to use Image as the submit button.

Answer


<!--from   ww  w  .  ja va  2 s  . c o  m-->

<html>
    <body>
        <form id="form1" method="post" action="javascript:console.log('Submitted')">
            <!-- regular textbox -->
            <label for="txtName">Name:</label><br />
            <input type="text" id="txtName" name="txtName" /><br />
            

            <!-- submit button -->
            <input type="image" src="http://www.java2s.com/style/logo.png" />
      
        </form>
    </body>
</html>

The code above is rendered as follows: