I am trying to style input type=file.
When I try to override the deault button with my custom buttom (so that I can styel it). The problem I am facing is when ever I click my custom button the form gets submitted and validation kicks in. Is there a way I can fix it.
HTML
<input type="file" name="upload" id="upload" class="upload"/>
<button class="fileButton" id="fileButton">Choose File</button>
<input type="submit" name="button" value="Contact Me" class="supportButton"></input>
Last input is my form submission button.
Javascript:
<script type="text/javascript">
$('#fileButton').click(function(){
$('#upload').click();
alert("input");
});
</script>
When I click my custom button, it triggers the file uplaod button ( I can browse and upload file) but at the same time it submits the form.
Fiddle: http://jsfiddle.net/uw5wqxpw/