Closed Thread Icon

Topic awaiting preservation: Hmmm, can't get a working regex for form field (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=8855" title="Pages that link to Topic awaiting preservation: Hmmm, can&amp;#039;t get a working regex for form field (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Hmmm, can&#039;t get a working regex for form field <span class="small">(Page 1 of 1)</span>\

 
smonkey
Paranoid (IV) Inmate

From: Northumberland, England
Insane since: Apr 2003

posted posted 09-11-2003 20:57

Me again, sorry guys.

I have the function below working so that if you haven't written in a text field when you click away from it the original value text returns. The thing is if some one has clicked on the text field and typed but then deleted it then they could have potentially left whitespace behind - and whilst whitespace isn't visible it makes the field value not empty so the onBlur bit doesn't work as intended.

So I'm looking for a regex that will be able to test the field value and check for anything but whitespace - if no proper charcters are found then revert to the original value text. I have tried testing things like /[^\S*]/ but I haven't got it working - maybe I'm just being dumb but I'm stuck.

[The Code]

<input type="text" name="n" value="Your message" onFocus="if(this.value=='Your message')this.value='';" onBlur="if(this.value=='')this.value='Your message'">

Thanks

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 09-12-2003 02:51

<input type="text" name="n" value="Your message" onFocus="if(this.value=='Your message')this.value='';" onBlur="if(/^\s*$/.test(this.value))this.value='Your message'">


« BackwardsOnwards »

Show Forum Drop Down Menu