-
jquery form field clear
i think this will help people a lot, cuz i couldn't find any simple answer by googling 3 hours...
i need a very very simple jquery form field reset.
here is the picture what i need:
HTML Code:
<script type='text/javascript' src='http://code.jquery.com/jquery-1.6.4.min.js'></script>
<script>
function reset_field() {
$('searchbox').val()=''
}
</script>
<form id='form'>
<input id='searchbox' type='text' name='q'>
</form>
<a href="#" onclick="call the resetting function">this link should clear the input field above</a>
this is what i need, of course the above example does not work. i just need the correct syntax for defining the reset function and correct syntax for how to call the function by a text link.
please help me, i know this issue will be so simple :eye:
but i just couldnt solve this problem :rolleyes:
-
Just checking, but did you know there is a native html input attribute for that? You can just use
Code:
<input type="reset">
within your form to provide a reset button for all fields. Apologies if you were looking for something different.
-
i have discovered the error
$('searchbox').val()=''
should be
$('#searchbox').val()=''
only # sign missing lol :D