javascript - Clear textfield in a form after submit -


i have following form:

<form onsubmit="chat.sendmsg(); return false;">     <label for="msg" style="float:left">message:</label>     <input type="text" id="msg" name="msg" autofocus="true" placeholder="type meassage here" />     <input type="submit" /> </form> 

and javascript goes it:

//for sending message this.sendmsg=function(){      msg=document.getelementbyid("msg").value;     chatzone.innerhtml+='<div class="chatmsg"><b>'+name+'</b>: '+msg+'<br/></div>';     oldata='<div class="chatmsg"><b>'+name+'</b>: '+msg+'<br/></div>';                this.ajaxsent();       return false; }; 

all works, when submit form, text stays in form. how clear textfield after hit enter/click submit?

ps dont use jquery

use this: document.getelementbyid("msg").value = '';

this.sendmsg=function(){        msg=document.getelementbyid("msg").value;       chatzone.innerhtml+='<div class="chatmsg"><b>'+name+'</b>: '+msg+'<br/></div>';       oldata='<div class="chatmsg"><b>'+name+'</b>: '+msg+'<br/></div>';                  this.ajaxsent();         document.getelementbyid("msg").value = '';//here       return false;  }; 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -