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


Groups > comp.lang.javascript > #17435

Re: IE9 is not a friend...

From Cezary Tomczyk <cezary.tomczyk@gmail.com>
Newsgroups comp.lang.javascript
Subject Re: IE9 is not a friend...
Date 2012-12-03 22:41 +0100
Organization Aioe.org NNTP Server
Message-ID <k9j69b$gdb$1@speranza.aioe.org> (permalink)
References <6de7edc4-756c-40a1-ae6b-98ba94062284@m13g2000vbd.googlegroups.com> <C6mdnSBWLPzeiCDNnZ2dnUVZ_sydnZ2d@westnet.com.au>

Show all headers | 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