Question

I have a mobile JQuery form and I want to reset it when I click the cancelar button . I have tried few codes but its not working

I am adding JSFiddle for it please have a look

<fieldset data-role="controlgroup" data-mini="true" style="color:#006699 !important">

<h4>Estoy interesado(a) En la propiedad, </h4>

    <input id="radio-choice-1" name="opcmessage" title="" type="radio" value="1" />
    <label for="radio-choice-1">favor de enviarme más información</label>
    <input id="radio-choice-2" name="opcmessage" title="" type="radio" value="2" />
    <label for="radio-choice-2">deseo visitarla</label>
    <input id="radio-choice-3" name="opcmessage" title="" type="radio" value="3" />
    <label for="radio-choice-3">envieme fotos</label>
    <input id="radio-choice-4" name="opcmessage" title="" type="radio" value="4" />
    <label for="radio-choice-4">envieme más fotos</label>
</fieldset>
<textarea name="textarea" id="textarea"></textarea>
<a data-rel="back" href="#pageone" id="reset" data-icon="delete" data-inline="true" data-role="button" data-theme="c" title="Close">Cancelar</a>

<div style="float: right; margin-right: -10px;">
    <input class="me" data-theme="c" data-role="button" data-inline="true" type="submit" data-icon="search" id="im_send_message" name="im_send_message" value="Enviar" />
</div>

FIDDLE

Was it helpful?

Solution

If you used form tag in JQuery mobile add a "id" to your form tag

**<form action="" id="myForm" method="post"> ... </form>**

And in

**$('#reset').click(function() { document.getElementById("myForm").reset(); });**

this will reset all your form element.

And you can add

**<input type="reset" name="reset" id="name" value="Reset" />**

Default functionality is to reset the form element. No need to write any code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top