Basic Date Picker Forums

Welcome to Basic Date Picker Forums Sign in | Join | Help
in Search

Js error?

Last post 06-01-2006, 12:04 AM by geoffrey.mcgill. 1 replies.
Sort Posts: Previous Next
  •  04-25-2006, 12:02 AM 482

    Js error?

    Using 1.1.1959 I was not able to client-side validate any dates that had a leading zero in the month field (UK format dd/MM/yyyy). Server side was ok. Had  a look at the validation code and the following doesn't make much sense:

    BDPLite.prototype.getInt = function(str,i,minlength,maxlength) {
        for (var x=maxlength; x>=minlength; x--){
            var valuePart = str.substring(i, i + x);
            if (valuePart.length < minlength) {
                return null;
            }
            if (this.isInteger(valuePart)) {
                for (var y = 0; y < valuePart.length; y++) {
                    if (valuePart.charAt(y) != "0")
                        return valuePart;
                    else
                        break;
                }
            }
        }
        return null;
    };

    When processing a month field eg, it gets called with the following params:  geInt("25/04/2006", 3, 2, 2)

    Which returns null for any month-value passed in with a leading zero. The second for loop will only ever execute once and either return a non-leading zero value or break out if there is a leading zero causing the "return null" at the end to get executed. I changed the function to return immediately if valuePart is an integer and it works fine. Am I missing something??

  •  06-01-2006, 12:04 AM 557 in reply to 482

    Re: Js error?

    Hi IcSmith,

    First off, we apologize for the incredibly late response to your post. It just kind of fell through the cracks. Sorry.

    As you noted, the code in question did create a bug and has been fixed in the upcoming v1.2 release.

    The code was changed to the following. See

    BDPLite.prototype.getInt = function(str,i,minlength,maxlength)
    {
          for(var x=maxlength; x>=minlength; x--)
          {
                var valuePart = str.substring(i, i + x);
                if(valuePart.length < minlength) { return null; }
                if(this.isInteger(valuePart))
                {
                   return valuePart;
                }
          }
          return null;
    };

    If you are interested in the v1.2 release, you can download a beta at the following location. See http://forums.basicdatepicker.com/forums/thread/505.aspx

    Please let us know if you have have any further questions or comments and we will do our best to help out.


    Thanks,
    Geoffrey McGill
    ----------------------------------------
    Coolite Inc.
    Email: support [at] coolite [dot] com
    Phone: +1(888)775-5888
View as RSS news feed in XML
 
Powered by Community Server, by Telligent Systems