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

Textbox allowing Alpha numeric characters with special characters hyphen and space.
First 6 letters should be alphabets...please get me an answer in jquery
Posted
Updated 24-Jun-14 18:43pm
v2
Comments
DamithSL 25-Jun-14 1:10am    
What have you tried? learn Regular Expressions[^] and try.

1 solution

Try a regular expression:
C#
public static Regex regex = new Regex(
      "^([a-zA-Z]{1,6}$)|([a-zA-Z]{6}[\\w- ]*$)",
    RegexOptions.IgnoreCase
    | RegexOptions.Multiline
    | RegexOptions.CultureInvariant
    | RegexOptions.IgnorePatternWhitespace
    | RegexOptions.Compiled
    );

Match m = regex.Match(InputText);
if (m.Success)
   {
   ...
 
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