简体   繁体   English

正则表达式 - 可被 500 整除

[英]Regular Expression - Divisible by 500

I am developing an MVC application and I have a requirement where there should be a instant client-side validation as soon as I enter a number in a textbox.我正在开发一个 MVC 应用程序,我有一个要求,只要我在文本框中输入数字,就应该立即进行客户端验证。 So I need a regular expression to write as a validation on top of the property in model class for that field.因此,我需要一个正则表达式来作为该字段在 model class 中属性之上的验证。

^[1-9]+[0-9]*00$ works for numbers divisible by 100 but am looking an expression which checks if the number divisible by 500. Can anyone help? ^[1-9]+[0-9]*00$ 适用于可被 100 整除的数字,但我正在寻找一个表达式来检查该数字是否可被 500 整除。有人可以帮忙吗?

Here is the eg for model validation where it checks if a number is divisible by 100这是 model 验证的示例,它检查数字是否可以被 100 整除

[Required] [RegularExpression(@"^[1-9]+[0-9]*00$ ", ErrorMessage = "Number not divisible by 100")] [必填] [RegularExpression(@"^[1-9]+[0-9]*00$ ", ErrorMessage = "不能被100整除的数字")]

public string EmployeeNumber{ get;公共字符串 EmployeeNumber{ 得到; set;放; } }

^(?:[1-9]\d*[05]00|500|0)$

A number is divisible by 500 if it ends with 000 or 500 .如果数字以000500结尾,则它可以被 500 整除。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM