Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello Experts,

I have web page that user inputs the data like Name, email, phone number. How can I restrict the user to enter only name in name field while entering.
Ex: Name: abc123--- It should say enter proper name before going to next control
Email:
Phone:

How to do this?
Posted
Comments
Richard Deeming 12-Jan-15 9:26am    
Define a "proper" name.

Start by reading Falsehoods Programmers Believe About Names[^] - particularly points 15 (People’s names do not contain numbers) and 17 (People’s names are not written in all lower case letters).
Sergey Alexandrovich Kryukov 12-Jan-15 21:16pm    
Makes no sense: any string can be called "name". Before requiring anything, require yourself to understand what you want.
—SA
[no name] 12-Jan-15 21:32pm    
Do you only want names that sudevsu approves of? Does your client/employer know this? Maybe you just want to create a bad experience for your users?

You can try easier techniques like tabindex and validations for the input controls to control this type of interactions.

But if you absolutely have to enforce a set sequence of activities, you could use a JavaScript/jQuery type function that does a validation on the values of the controls in the sequence you like and then if any control has an empty value, set the focus on that control and exits the function.

This function could be triggered on tab out events for the controls and on page load event for the page.
 
Share this answer
 
hi,
hope this will help full for you.

You can use Regular Expressions, for your better understating some examples are here.



Regular Expressions (Mozila)

&
[^]


[^]
http://stackoverflow.com/questions/46155/validate-email-address-in-javascript[^]
 
Share this answer
 
v3

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