Search code examples
htmlformsreset

why does the input type=reset is not working?


Here is the code. When I try to use input type reset, it is not working. I tried to remove it outside the div, still it's not working.

<div class="container-fluid">
    <div class="row">
        <div class="col s4"></div>
        <div class="col s4">
            <form class="form"  action="<?=base_url()?>item/updatedata/<?=$this->uri->segment(3)?>" method="POST">
                <div class="row">
                    <label>ITEM ID</label>
                    <input type="text" readonly="" value="<?=$items->item_id?>" class="validate">
                    <label>ITEM NAME</label>
                    <input type="text" value="<?=$items->item_name?>" name="item_name" class="validate">
                    <label>ITEM DESCRIPTION</label>
                    <input type="text" value="<?=$items->item_desc?>" name="item_desc" class="validate">
                    <label>ITEM PRICE</label>
                    <input type="text" value="<?=$items->item_price?>" name="item_price" class="validate">
                    <div class="col s6">
                        <button class="btn waves-effect waves-light " type="submit" value="SUBMIT">Submit
                            <i class="material-icons right">send</i>
                        </button>
                    </div>
                    <div class="col s6">
                        <input  class="btn waves-effect waves-light red" type="reset" value="Reset">
                    </div>
                </div> 
            </form>
        </div>
        <div class="col s4"></div>
    </div>
</div>

Solution

  • The input type reset resets all form values to default values.

    Since for all input elements, you have given a value, this acts as the default value for those elements.

    When you click Reset button, all the values are set to default values that you have given.

    If you remove value attributes, the reset will set all the values to blank (in case of text), and it will work as you expected.