Results 1 to 2 of 2

Thread: String.prototype problem

  1. #1
    Join Date
    Nov 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default String.prototype problem

    I am trying to create a custom method for all Strings.

    Code:
    var chkStr = {
      
      isBlank: function() {
        if (this.length < 1) return false; 
        else return true;
      },
    }
    
    String.prototype.isBlank = new chkStr.isBlank;
    Later in a function I check the value of a form entry

    Code:
    if (form.formName.field.value.isBlank) {
      alert('You left something blank.');
    }
    I am getting a myStr.isBlank is not a function error.
    Last edited by k_rizza; 11-10-2009 at 02:40 PM.

  2. #2
    Join Date
    Nov 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default UPDATE: I had the wrong problem

    Due to a parsing error chkStr.isBlank was not being considered a function.

    This was due to something I have not properly identified, but it is definitely not what I thought it was. I am not able to delete this thread and feel like a dunce for negating it so quickly.

    Thank you all who go out of their way to help others and took the time to consider helping me.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •