Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
Node is saved as draft in My Content >> Draft
  • Regular Expression in MVC

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 35
    Comment on it

    While doing validation you need to put validation apart from that you need to provide the regular expression

     

    in cases where only specific values are allowed to enter otherwise user cannot enter it

     

    Regular expressions are series of combinations of letters and symbols that will provide this work for us

     

     public class Details
        {
    
    
            [Required]
            [Display(Name = "Name")]
            [RegularExpression(@"^[a-zA-Z]+$", ErrorMessage = "Use letters only please")]
            public string Name;
    
            [Required]
            [Display(Name = "DOB")]
            public string dob;
    
            [Required]
            [Display(Name = "Hobbies")]
            public IEnumerable<SelectListItem> Hobbies;
    
            [Required]
            [Display(Name = "Country")]
            public IEnumerable<SelectListItem> Country;
    
            [Required]
            [Display(Name = "Category")]
            public IEnumerable<SelectListItem> Category;
    
    
            public string getcategory;
    
    
            public string getcountry;
    
            public string gethobbies;
    
            public string value;
        }

     

     

    In this model class i have done validation to enter only characters while providing name of the user in the registeration process

    .net

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: