Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #17435

Re: IE9 is not a friend...

Path csiph.com!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail
From Cezary Tomczyk <cezary.tomczyk@gmail.com>
Newsgroups comp.lang.javascript
Subject Re: IE9 is not a friend...
Date Mon, 03 Dec 2012 22:41:01 +0100
Organization Aioe.org NNTP Server
Lines 34
Message-ID <k9j69b$gdb$1@speranza.aioe.org> (permalink)
References <6de7edc4-756c-40a1-ae6b-98ba94062284@m13g2000vbd.googlegroups.com> <C6mdnSBWLPzeiCDNnZ2dnUVZ_sydnZ2d@westnet.com.au>
NNTP-Posting-Host RMrsF+s1qSnxq5Qkkqjnpw.user.speranza.aioe.org
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Complaints-To abuse@aioe.org
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/17.0 Thunderbird/17.0
X-Notice Filtered by postfilter v. 0.8.2
Xref csiph.com comp.lang.javascript:17435

Show key headers only | View raw


W dniu 2012-12-03 22:10, Andrew Poulos pisze:
[...]
> What about testing for
>    if (!document.getElementById(fourFields[i]).value.length) {
> instead? Also I'd put 'i' in with 'var' ie
>    var i, fourFields...
> and add
>    var len = fourFields.length;
>    for (i = 0; i < len; i++) {

document.getElementById(fourFields[i]).value.length counting also 
spaces. So, if field contains only spaces then the question is: "Is it 
still empty field?". From amount of characters point of view - no, field 
is not empty, but for me, logically field is empty if contains only: 
spaces, tab characters, white-spaces or "new line character".

Personally I use something extra (except checking length) to be sure if 
field is really empty:

var isEmpty = (function(){
    var notEmpty = new RegExp('[^\\t\\n\\r ]');

    return function(str){
       if(typeof str !=== 'string'){
          return false;
       }
       return !notEmpty.test(str);
    }

}());

-- 
Cezary Tomczyk
http://www.ctomczyk.pl/

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

IE9 is not a friend... justaguy <lichunshen84@gmail.com> - 2012-12-03 13:04 -0800
  Re: IE9 is not a friend... Andrew Poulos <ap_prog@hotmail.com> - 2012-12-04 08:10 +1100
    Re: IE9 is not a friend... Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2012-12-03 22:41 +0100
      Re: IE9 is not a friend... justaguy <lichunshen84@gmail.com> - 2012-12-03 14:06 -0800
        Re: IE9 is not a friend... justaguy <lichunshen84@gmail.com> - 2012-12-03 14:27 -0800
        Re: IE9 is not a friend... Christoph Becker <cmbecker69@gmx.de> - 2012-12-04 15:05 +0100
      Re: IE9 is not a friend... Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-12-03 23:20 +0100
        Re: IE9 is not a friend... Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2012-12-03 23:41 +0100
          Re: IE9 is not a friend... Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-12-04 15:23 +0100
            Re: IE9 is not a friend... Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2012-12-04 16:12 +0100
    Re: IE9 is not a friend... Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-12-03 23:15 +0100
  Re: IE9 is not a friend... "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-12-03 23:15 +0200

csiph-web