简体   繁体   中英

Empty the text box if data's are entered

Data's entered in the popup text box gets cleared if cancel button is pressed.

I used the below code for performing this,

function clear()
{
 document.getElementById("spacevalidate").setTextValue() = "";
}

html is for popup box is

<div id="overlay_form" style="display:none">
       <h2> Create New Incident Type</h2>
        <br />
        Name
        <input type="text" id="spacevalidate" style="height:30px;" name="title" maxlength="30" /><br />
        <div style="width:180px;float:right;margin:20px 5px 0 10px">
            <button id="bsave" type="submit" name="save" title="Save" class="forward">Save</button>
            <button style="margin-right:10px;" type="button" id="close" name="cancel" class="forward backicon">Cancel</button>
        </div>

update:

$(document).ready(function(){
        //open popup
        $("#addalist").click(function(){
            $("#overlay_form").fadeIn(1000);
            positionPopup();
        });

1.Now i enter some data and press cancel button,again i open the same popup,data's are avail in the text box.I want to clear that on every open if some data's entered and cancel button is pressed.

Try this,

function clear()
{
   document.getElementById("spacevalidate").value = "";
}

正如Cam所说,只需在打开模式的函数中调用clear()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM