Samuel Charpentier
Samuel Charpentier

Reputation: 609

How can I replace my submit button with an image?

I have made this simple search box and want to use an svg image as the submit button, how could I do that without any javascript?

here's the form:

    <form method="post" action="#">
        <input type="text" name="rechercher" id="rechercher" placeholder="Rechercher"/>
        <input type="submit" value="none" onerror="this.onerror=null; this.src='images/loupe.png'"/>
    </form>

Upvotes: 2

Views: 10128

Answers (2)

user3373870
user3373870

Reputation: 1466

You can use an image button on the button

<input type=image src=PATH_TO_YOUR_IMAGE alt="Submit Me">

or set submit button background to an image using css

input[type=submit] {
    background:url(BACKGROUND_IMAGE_PATH_HERE);
    border:0;
    display:block;
    height:Change_TO_backgroundimageheight;
    width: Change_To_backgroundimageWidth;
}

Upvotes: 5

TBAR
TBAR

Reputation: 448

<form action="demo_form.asp">
First name: <input type="text" name="fname"><br>
<input type="image" src="submit.gif" alt="Submit">
</form>

The long and short is input type image will also submit the form

Upvotes: 4

Related Questions