Click here to Skip to main content
15,896,269 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
	Account No* – Minimum and maximum of 8 numbers only.  It should accept the first number is a "0" only 


	BSB* – Minimum and maximum of 6 numbers only.  ACCEPTABLE FORMAT IS :   000-000 (this is example only.  Length:  must be 6 numbers only. 


What I have tried:

[Required(ErrorMessage = "Please enter the BSB")]
       [Display(Name = "BSB")]
       [RegularExpression("^[0-9]*$", ErrorMessage = "Please Enter only Numbers")]
       [StringLength(6, ErrorMessage = "The BSB must be 6 numbers only.", MinimumLength = 6)]
       public string BSB { get; set; }

       [Required(ErrorMessage = "Please enter the AccountNo")]
       [RegularExpression("^[0-9]*$", ErrorMessage = "Please Enter only Numbers")]
       [StringLength(8, ErrorMessage = "The BankAccountNo must be 8 numbers only.", MinimumLength = 8)]
       public string BankAccountNo { get; set; }
Posted
Updated 19-Apr-17 2:54am
v2
Comments
Kats2512 19-Apr-17 3:34am    
so what is the problem? Your question is not clear at all
VenkataSeshu B 19-Apr-17 3:38am    
While entering values in textboxes need to display 000-000 like this format for BSB number and for accountno first value must be 0

this is my validation requirement
Sinisa Hajnal 19-Apr-17 6:21am    
Please ask the question - you're using some validation already, but not saying what is wrong, what error do you get or what you're expecting
VenkataSeshu B 19-Apr-17 6:24am    
need to accept textbox value starting number 0 only for accountno otherwise it should rise error message

1 solution

Change your expression for Bank a/c# to
C#
"^0[0-9]{7}$"
and BSB to
C#
"^[0-9]{3}-[0-9]{3}$"

You might also want to change the length of the BSB to 7 to accommodate the separator.
 
Share this answer
 
Comments
VenkataSeshu B 19-Apr-17 9:12am    
Thank u athar
now it is working fine

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