My requirement is, I have one text box and that text box accepts US Format 10 digit phone number like 555-555-5555. I want when user enter 5555555555 it automatically convert this in 555-555-5555 and if he enter some wrong number then show him error and if dont want to enter any thing then there should not be any error.
My code is:-
<%--
ControlExtender="meeHome" InvalidValueMessage="Valid Telephone Number is required."
IsValidEmpty="false" ValidationExpression="^\d{3}-\d{3}-\d{4}$" Font-Size="8pt" />--%>
Whats happenening, If i entered any thing like 5555555555 and it is coverting to this 555-555-5555 format which is correct and then when i moved to another textbox it is throwing error "Invalid Home number. Number should be in the format: 555-123-4567" and this format changes to 5555555555 and its not going ahead.
Any idea?
Ajay GautamPosted Oct 28, 2010, 7:09 PM
Let me know if you need any other information
This is my final code: -
IsValidEmpty="false"
If i am making ClearMaskOnLostFocus="true"
if i entered 123-546-7892 and when i press tab then it converts this 123-546-7892 to 1235467892 and throws error that "Valid Telephone Number is required"
If i am making ClearMaskOnLostFocus="false"
Then by default this textbox has ___-___-____ and i did not put any value then it is throwing error if i use tab from one textbox to another textbox, it should not throw because i am not putting any value. if i will not come on this textbox no tab, then it is fine,
any idea?
Suthish NairPosted Oct 28, 2010, 3:25 PM
Ajay GautamPosted Oct 28, 2010, 11:33 AM
Now whats happening,
if ClearMaskOnLostFocus="true" then
if i entered 123-546-7892 and when i press tab then it converts this 123-546-7892 to 1235467892 and throws error that "Valid Telephone Number is required"
If
if ClearMaskOnLostFocus="true" then
Now Suppose i press tab and moved to another textbox, by default this textbox has ___-___-____ and i did not put any value then it is throwing error, it should not throw because i am not putting any value. if i will not come on this textbox no tab, then it is fine, any idea?
Suthish NairPosted Oct 28, 2010, 11:11 AM