Click here to Skip to main content
15,880,796 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

i want a number format like 333-333-333-3333.

ie., as soon as i enter a 13digit number it should split automatically the given number with -

each hyphen gap should be 3 digits.

and also i don't want to accept more than a 13digit number.

how to solve this?


Regards,
Pawan
Posted

 
Share this answer
 
v2
Comments
Alain Bertrand 7-Jul-10 5:27am    
Reason for my vote of 5
seems the right way to display it.
Pawan Kiran 7-Jul-10 6:30am    
Reason for my vote of 5
after i posted the question i looked into maskededit textbox, it satisfy my need up to maximum extent..
Kunal Chowdhury «IN» 7-Jul-10 9:04am    
Reason for my vote of 5
This is only the MaskEdit control which will solve the problem asked by Pawan.
If you want to split one 13 digit number into 4 numbers, then surely Split is the way.

If it's just the way for some validation or input taking then I would suggest you to use a masked textbox to take the input.
Mask TextBox ASP.NET Control[^]
Enhanced Textbox Control[^]

There are few similar control based article here at code project itself.
This sort of control would restrict only given number of digits, no less no more in a specified format. Change it as per your need.
 
Share this answer
 
v2
Comments
Pawan Kiran 7-Jul-10 6:34am    
Reason for my vote of 4
firstlink is useful for me to acheive the desired output.but the problem is i can't find the exact location to change the code inorder to get the output which i want. anyhow i wil try to edit it according to my need..
You need to use a validator to enforce your format. Use the string.Split method to turn it into seperate numbers.
 
Share this answer
 
for not accepting more than 13 digit number you can use regular expression validator.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900