It not only allows leaving off the cents, but will accept part of a decimal: the decimal point followed by zero, one, or two digits.If the number is valid, the function then determines what part if any of the decimal is missing and adds the necessary characters (zeroes and decimal point).If the data is trimmed before validating with an alltrim covered previously, data otherwise valid will pass this test.The third regular expression is the same as the second with the addition of that restricts the data to having 3 to 5 of the preceding character(s) in this case digits.
These were, however, still strings since the results of any mathimatical operation using them is meaningless. Numerical data is alway handled as string representations of numbers in (X)HTML forms or when the data is sent to the server.Of course, positive and negative integers are common, and positve integers frequently omit the sign so this requires a little consideration.A valid integer value should contain only digits and possibly a leading minus or plus sign.In this example we can determine whether a user entered phone number in a common format that includes Similarly if we want to validate phone number like xxx-xxx-xxxx format then you can use “\d-\d-\d”.If you want to use regular expression for validating phone or mobile numbers followed by country code. Net, Silverlight, HTML, XML, Crystal Report, Active Reports, Infragistics, Component Art, Compone One, Lead Tools etc.
However, it is a good idea to trim data before validating using alltrim covered previously.