Wednesday, March 21, 2012

Trouble with mask validator

Hello i want to use a mask like this (999)999-9999 for a telephone number, but the mask InvalidValueBlureedMessage validation is not successful, i dont know if this is happening because the mask doesnt have the ( ) as Character separator and neither the - symbol. So what can i do ?

And also since im validating a field that isnt required, i want the mask shows only when the field has the phone numbers, but if i set theClearMaskOnLostFocus propertie to true, the mask stills on the field even if i dont have a phone number, but i dont want to save the mask in the database, and if i set theClearMaskOnLostFocusto false the mask is deleted and i have just the numbers and i need save the numbers with mask too. How can i set the mask in order to be displayed when it has and only have the full telephone number, im assuming the InvalidValueBlureedMessaga validation is alredy solved.

Thanks!

Hi Tarkan,

tarkan:

Hello i want to use a mask like this (999)999-9999 for a telephone number, but the mask InvalidValueBlureedMessage validation is not successful, i dont know if this is happening because the mask doesnt have the ( ) as Character separator and neither the - symbol. So what can i do ?

I think you should use MaskedEditExtender + MaskedEditValidator. Use MaskedEditExtender to format its display style and use MaskedEditValidator to validate it.

<ajaxToolkit:MaskedEditExtender ID="MaskedEditExtender1" runat="server" TargetControlID = "TextBox1"
MaskType ="None" Mask ="(999)999-9999" DisplayMoney="Left"
InputDirection ="RightToLeft" ClearMaskOnLostFocus="false"></ajaxToolkit:MaskedEditExtender>

And MaskedEditValidator's ValidationExpression should be "/\(\d{3}\)\d{3}-\d{4}/";For example,

<ajaxToolkit:MaskedEditValidator ID="MaskedEditValidator2" runat="server"
ControlExtender="MaskedEditExtender1"
ControlToValidate="TextBox1"
IsValidEmpty="False" ValidationExpression ="\(\d{3}\)\d{3}\-\d{4}"
EmptyValueMessage="input is required"
InvalidValueMessage="input is invalid"
Display="Dynamic"
TooltipMessage="(999)999-9999"
EmptyValueBlurredText="*"
InvalidValueBlurredMessage="*"
MaximumValueBlurredMessage="*"
MinimumValueBlurredText="*"
ValidationGroup="MKE" />

tarkan:

And also since im validating a field that isnt required, i want the mask shows only when the field has the phone numbers, but if i set theClearMaskOnLostFocus propertie to true, the mask stills on the field even if i dont have a phone number, but i dont want to save the mask in the database, and if i set theClearMaskOnLostFocusto false the mask is deleted and i have just the numbers and i need save the numbers with mask too. How can i set the mask in order to be displayed when it has and only have the full telephone number, im assuming the InvalidValueBlureedMessaga validation is alredy solved.

Based on my knowledge,there's no pefect solution. Would you please post it as a suggestion to codeplex website? Our developers will evaluate them seriously and take them into consideration when designing future release of the product.Improving the quality of the products and services is a never-ending process for Microsoft.

Best regards,

Jonathan

No comments:

Post a Comment