Int or Number DataType for DataAnnotation validation attribute

前端 未结 8 2492
我寻月下人不归
我寻月下人不归 2020-12-07 10:41

On my MVC3 project, I store score prediction for football/soccer/hockey/... sport game. So one of properties of my prediction class looks like this:

[Range(0         


        
8条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-07 10:55

    Try one of these regular expressions:

    // for numbers that need to start with a zero
    [RegularExpression("([0-9]+)")] 
    
    
    // for numbers that begin from 1
    [RegularExpression("([1-9][0-9]*)")] 
    

    hope it helps :D

提交回复
热议问题