I need regular expression for validating version number using asp.net RegularExpressionValidator control. Please find below valid and invalid version numbers
Valid
1.1
1.1.3.4
1.0
1.1.334
Invalid
1
1.
1..
Thanks in advance.
Do not use a regular expression for this. Rather use .NET's Version
type:
Version v;
if (Version.TryParse(input, out v)) {
// Valid
} else {
// Not valid.
}
For more details (eg. ensuing there is more than one component to the version you can use the properties of the Version
instance).
EDIT: To do this client side in JavaScipt, there is no such helper, but based on your examples something like:
^\d+(\.\d+)+$
should work.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments