Board index » javascript » what does this.value.replace().replace() do?
|
Geoff Cox
Registered User |
what does this.value.replace().replace() do?
2008-02-06 04:32:07 AM
Hello, Amrit has posted the code below for keeping the focus on a text box until some text is entered. Can someone please explain how {if(this.value.replace(/^\s+/,"").replace(/\s+$/,"") == "") focus();} works - I don't understand the this.value.replace().replace() part.... Thanks Geoff function focus() { if(typeof document.MyForm.username.onblur != "function") document.MyForm.username.onblur = function() {if(this.value.replace(/^\s+/,"").replace(/\s+$/,"") == "") focus();} alert("please add your first and last names before continuing"); document.MyForm.username.focus(); } - |
