[BUG/REQUEST]RequiredFieldValidator should trim the string before checking the length

Last post 04-06-2006 6:28 PM by Luis Abreu. 4 replies.

Sort Posts:

  • [BUG/REQUEST]RequiredFieldValidator should trim the string before checking the length

    04-01-2006, 12:24 PM
    • All-Star
      25,662 point All-Star
    • Luis Abreu
    • Member since 02-12-2005, 1:22 AM
    • Madeira [Portugal]
    • Posts 5,368
    • TrustedFriends-MVPs

    hello guys.

    today i'm playing with the validator controls. looking at the source code of the requiredfieldvalidator, i see this:

    this

    .validate = function(value) {
    if (!value) {
       return false;
    }
    if (String.isInstanceOfType(value)) {
    if (value.length == 0) {
         return false;
    }
    }
    return true;
    }

    shouldn't the value be trimmed before checking the length? if we don't do that, an empty space is considered to be ok. btw. one more question: shouldn't validation be fired when the textbox looses its focus? currently this doesn't happen and due to that the requiredfieldvalidator doesn0t work properly!

    thanks

    --
    Regards,
    Luis Abreu
    email: labreu_at_gmail.com
    EN blog:http://msmvps.com/blogs/luisabreu
  • Re: [BUG/REQUEST]RequiredFieldValidator should trim the string before checking the length

    04-06-2006, 6:04 PM
    • Contributor
      5,514 point Contributor
    • Eilon
    • Member since 06-26-2002, 6:14 PM
    • Redmond, WA
    • Posts 945
    • AspNetTeam

    Hi Luis, I have opened a suggestion bug to track this. We will investigate it for a future CTP.

    Thanks,

    Eilon

    Blog: http://weblogs.asp.net/LeftSlipper/
  • Re: [BUG/REQUEST]RequiredFieldValidator should trim the string before checking the length

    04-06-2006, 6:12 PM
    • All-Star
      25,662 point All-Star
    • Luis Abreu
    • Member since 02-12-2005, 1:22 AM
    • Madeira [Portugal]
    • Posts 5,368
    • TrustedFriends-MVPs

    Hello Eilon.

    well, it's that currently, this control doesn't "feel" good. for instance, to get it to work properly you have to:

    1. write something
    2. select another control (remove focus from the validated textbox)
    3. go back and delete the content
    4. remove focus from the control

    this will make the validator do its work...however, if i just don't write anything in the textbox, then the validator won't do its validation (because there's no propertychanged event) and the info will be considered valid.

    btw, one more question: any chance of expanding the validators so that they can be applied to other form controls?

    --
    Regards,
    Luis Abreu
    email: labreu_at_gmail.com
    EN blog:http://msmvps.com/blogs/luisabreu
  • Re: [BUG/REQUEST]RequiredFieldValidator should trim the string before checking the length

    04-06-2006, 6:20 PM
    • Contributor
      5,514 point Contributor
    • Eilon
    • Member since 06-26-2002, 6:14 PM
    • Redmond, WA
    • Posts 945
    • AspNetTeam

    Hi Luis,

    Regarding the first part, we will try to address that as part of the bug I opened.

    Regarding the second part, the validators should work on any control that is an InputControl. Do you have specific controls in mind that we don't currently validate? You should also be able to implement your own controls that support validation, if you have some kind of custom UI that isn't directly represented by an HTML element.

    Thanks,

    Eilon

    Blog: http://weblogs.asp.net/LeftSlipper/
  • Re: [BUG/REQUEST]RequiredFieldValidator should trim the string before checking the length

    04-06-2006, 6:28 PM
    • All-Star
      25,662 point All-Star
    • Luis Abreu
    • Member since 02-12-2005, 1:22 AM
    • Madeira [Portugal]
    • Posts 5,368
    • TrustedFriends-MVPs

    hello.

    if i'm not mistaken, that means that only textbox controls can be validated. am i wrong? and if a value on a drop down must be x when y is entered on a textbox? can i apply a validator to the drop down (ie, atlas select control). i'm almos positive that you can't apply a validator to a drop down...though o hope i'm wrong.

    btw, you should note that, in my opinion, this is not one of those things that really MUST be included in atlas (for instance, i guess that in my case, i'll still be using the aso.net validators - provided that those issues i've mentioned in previous posts have been taken care of :) )...

    --
    Regards,
    Luis Abreu
    email: labreu_at_gmail.com
    EN blog:http://msmvps.com/blogs/luisabreu
Page 1 of 1 (5 items)