Click here to Skip to main content
15,891,473 members
Please Sign up or sign in to vote.
2.33/5 (2 votes)
See more:
Hi All,

I have a textbox which currently allows only 7 digit number. Now along with current scenario, I want to allow it to accept digits, alphabets and spaces also. How to do this? Can we have multiple masks at the same time on same textbox?

Also my 2nd Question is:

If i want to maintain a table in the database with all the defined formats which textbox should accept and then checking those formats when user enters value in textbox. Is it possible? If possible then the biggest advantage is that, every time if user wants some different format then i will just update my back end which in turn avoids code change.

Thanks
Surendra
Posted

If you have the source code for this masked box, you can change the source code to accept additional characters.
If not, request the author of this control to provide these additions if possible.
 
Share this answer
 
Ans for Q1 :

Yes you can.For that you have to use Regular-Expressions

Check here for more info : The Premier website about Regular Expressions

Ans for Q2 :

You need to maintain just a string filed on your table.

Hence you're using MVC,you can validate your user inputs by using above mentioned reg-exp on client side itself.
 
Share this answer
 
v2
Comments
Surendra Patil 21-Jan-14 3:27am    
Hi Sampath,

Can you please elaborate a bit on Q2 ans.
Sampath Lokuge 21-Jan-14 3:31am    
Can you tell me what's not clear for you ?
Surendra Patil 21-Jan-14 3:33am    
I am not clear about how to do this.
Sampath Lokuge 21-Jan-14 3:36am    
Please check this link for get more knowledge about how to do client side validations with reg-exp.
http://stackoverflow.com/questions/8244572/dataannotations-validation-regular-expression-in-asp-net-mvc-4-razor-view

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