Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 920
  • Last Modified:

MaskedEdit empty textbox problem

Hi there,
I have a textbox that takes phone numbers from users. The field is not requiered but if you click on the textbox it expects a numbers and thats not what i want. How can i solved my issue?
attached is what i have.
Thanks for your help
<asp:TextBox ID="txtPhoneNumber" runat="server" Width="248px" ValidationGroup="MKE"/>
                                <ajaxToolkit:MaskedEditExtender ID="MaskedEditExtender1" runat="server"
                                TargetControlID="txtPhoneNumber"
                                Mask="999-999-9999"
                                ClearMaskOnLostFocus="false"
                                ClearTextOnInvalid="true"
                                MessageValidatorTip="true"
                                OnFocusCssClass="MaskedEditFocus"
                                OnInvalidCssClass="MaskedEditError"
                                MaskType="None"
                                InputDirection="LeftToRight"
                                AcceptNegative="Left"
                                DisplayMoney="Left" Filtered="-"
                                ErrorTooltipEnabled="True" />
                                <ajaxToolkit:MaskedEditValidator ID="MaskedEditValidator1" runat="server"
                                ControlExtender="MaskedEditExtender1"
                                ControlToValidate="txtPhoneNumber"
                                IsValidEmpty="true" ValidationExpression ="[0-9]{3}\-[0-9]{3}\-[0-9]{4}"
                                InvalidValueMessage="input is invalid"
                                Display="Dynamic"
                                TooltipMessage="XXX-XXX-XXXX"
                                InvalidValueBlurredMessage="Please input the right phone number!"
                                ValidationGroup="MKE" />

Open in new window

0
COHFL
Asked:
COHFL
  • 15
  • 7
  • 5
1 Solution
 
silemoneCommented:
ValidationExpression ="[0-9]{3}\-[0-9]{3}\-[0-9]{4}"
 is validating looking for a number
0
 
msiceCommented:
Get rid of ValidationExpression ="[0-9]{3}\-[0-9]{3}\-[0-9]{4}" Sounds like you dont need a validator at all. If empty is ok and you dont need only numbers.
0
 
silemoneCommented:
if you don't want that then remove validator
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
COHFLAuthor Commented:
no, i do need only numbers when fill if the users leaves empty is ok
0
 
silemoneCommented:
so you want it to allow empty, yes

([0-9][0-9][0-9]-[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]){0,1}
0
 
silemoneCommented:
ValidationExpression ='^([0-9][0-9][0-9]-[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]$){0,1}'
should allow 0 or 1 phone numbers
0
 
silemoneCommented:
ValidationExpression ='([0-9][0-9][0-9]-[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]){0,1}'
should allow 0 or 1 phone numbers
0
 
silemoneCommented:
you can go for a more complex regular expression that picks the same number, but my solution is pretty straight forward...

let me know if you have further specs.
0
 
COHFLAuthor Commented:
ok any of your solutions worked.

when i click on my textbox without entering any values and i click away in somehting else there is the error "Please enter valid phone munber".
what can i do?
0
 
msiceCommented:
go to the txtPhoneNumber properties and remove the validation or remove the validator it is using.
0
 
msiceCommented:
get rid of
ValidationGroup="MKE"

and all of this
<ajaxToolkit:MaskedEditExtender ID="MaskedEditExtender1" runat="server"
                                TargetControlID="txtPhoneNumber"
                                Mask="999-999-9999"
                                ClearMaskOnLostFocus="false"
                                ClearTextOnInvalid="true"
                                MessageValidatorTip="true"
                                OnFocusCssClass="MaskedEditFocus"
                                OnInvalidCssClass="MaskedEditError"
                                MaskType="None"
                                InputDirection="LeftToRight"
                                AcceptNegative="Left"
                                DisplayMoney="Left" Filtered="-"
                                ErrorTooltipEnabled="True" />
                                <ajaxToolkit:MaskedEditValidator ID="MaskedEditValidator1" runat="server"
                                ControlExtender="MaskedEditExtender1"
                                ControlToValidate="txtPhoneNumber"
                                IsValidEmpty="true" ValidationExpression ="[0-9]{3}\-[0-9]{3}\-[0-9]{4}"
                                InvalidValueMessage="input is invalid"
                                Display="Dynamic"
                                TooltipMessage="XXX-XXX-XXXX"
                                InvalidValueBlurredMessage="Please input the right phone number!"
                                ValidationGroup="MKE" />
0
 
silemoneCommented:
refresh you IE...those solutions should work...

msice, he wants phone number validation, but he also wants the ability for it be empty

sort of like: it can be phone # or empty string and that's it
0
 
silemoneCommented:
msice - see his initial response back...
0
 
silemoneCommented:
InvalidValueBlurredMessage="Please input the right phone number!"  <-- erase this and try
0
 
msiceCommented:
Ah ok sorry I misread what he was wanting.
0
 
COHFLAuthor Commented:
silemone,
Still your solution did not work. If i do removed that blurredmessage the other message comes up "Input is invalid"
0
 
silemoneCommented:
good.then it must be my regular expression..i will test it...
0
 
silemoneCommented:
did you refresh your browser also? ie go to internet options and clear history, files, etc. and then try?
0
 
COHFLAuthor Commented:
yes i have clear my history
0
 
msiceCommented:
have you tried:
((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}
0
 
silemoneCommented:
http://www.regular-expressions.info/javascriptexample.html

I tested the regular expression...it works in on the attached page so it must be some other option that we have not looked into...
0
 
silemoneCommented:
well that other tester was garbage.

this one finds match http://www.quanetic.com/Regex...hmmm


0
 
COHFLAuthor Commented:
msice, this did not work ((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}
0
 
COHFLAuthor Commented:
Silemone where are you getting at? one link is just not working and the second one just show how regex work uhmmm how do this solve my issue?
0
 
silemoneCommented:
i was giving you hard evidence that the regular expression is not where we need to be looking..by the way, the 1st link was garbage...seems like everything always came back true...
0
 
COHFLAuthor Commented:
ok i got the answer:
<ajaxToolkit:MaskedEditExtender ID="MaskedEditExtender1" runat="server"
                                TargetControlID="txtPhoneNumber"
                                Mask="999-999-9999"
                                MessageValidatorTip="true"
                                OnFocusCssClass="MaskedEditFocus"
                                OnInvalidCssClass="MaskedEditError"
                                MaskType="Date"
                                DisplayMoney="Left"
                                AcceptNegative="Left"
                                ErrorTooltipEnabled="True" />
                                <ajaxToolkit:MaskedEditValidator ID="MaskedEditValidator1" runat="server"
                                ControlExtender="MaskedEditExtender1"
                                ControlToValidate="txtPhoneNumber"
                                EmptyValueMessage="Phone Number is required"
                                InvalidValueMessage="Phone Number is invalid"
                                Display="Dynamic"
                                TooltipMessage="Input a Phone Number"
                                EmptyValueBlurredText="*"
                                InvalidValueBlurredMessage="*"
                                ValidationGroup="MKE" />
0
 
silemoneCommented:
we offered that solution in the beginning...lol...well as long as you got the answer...
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 15
  • 7
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now