Human height, weight checking in asp.net

I try to do height (person height) and weight check.

The height should look something like this: 5'11"

Anything in any other format should appear as incorrect.

What should I use for ValidationExpression?

and one more question "[10-200]. (1 [0-1] | \ d)" is correct for checking the weight

+3
source share
3 answers

A simple regular expression for a reasonable height in feet / inches would be:

[2-7]'(1[01]|\d)(''|")

For ASP.NET ValidationExpression, it will be something like:

<asp:RegularExpressionValidator id="myHeightRegex" runat="server"
                                ControlToValidate="txtName"
                                ValidationExpression="[2-7]'(1[0-1]|\d)(''|\")"
                                ErrorMessage="Invalid Height" Display="Dynamic" />
+2
source

Switch to metric :-)

180 cm or even 1803 mm if you want accuracy

ENTIRE

+1

why not just use two fields and make sure that the values ​​are integers with a certain range (range checker) (the inch field may be empty) - then you don't have to bother with regular expressions all day.

+1
source

Source: https://habr.com/ru/post/1731657/


All Articles