Seshu B

Seshu B

  • 1.6k
  • 439
  • 94.8k

How to give validation for accountno and BSB no in MVC

Apr 19 2017 3:07 AM
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.

I have tried this :-

[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; }

Answers (1)