I have a form with a reset button and what I want is to reset only some form elements when that button is clicked.

<form name="frmMyForm">
<input type="text" name="txtText" />
<input type="checkbox" name="chkCheckBox" />

<input type="reset" value="reset" />
</form>

Now I want the checkbox to be reset when I click the reset button is clicked and let the textbox retain its value
Is it possible?

I don't know if this is the BEST way to do it, but this would work :

<head>
    
        <script language="javascript">
        function fnMyReset() {
            document.frmMyForm.chkCheckBox.checked = false;
        }
        </script>
    
    </head>
    
    <body>
    
        <form name="frmMyForm">
        
            <input type="text" name="txtText" />
            <input type="checkbox" name="chkCheckBox" />
            
            <!-- changed from type="reset" to type="button" -->
            <input type="button" value="reset" onclick="fnMyReset()" />
        
        </form>
    
    </body>

Use a regular button with the word RESET on the face. Use it to call a function to put default values in the ones you want to reset. I wrote several of these.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.