c# - to perform validation for amout(price) in ASP.net -


I am using 'zodiac' as the column in my statistics for my application.

I want

1) I want to know that there is more than 2 digits after the decimal point in the sum

2) If the amount is positive or negative .. (as it needs to be shown in case of negative error message)

Can you help with less and efficient code snippets ??? Edit: @Peter:

But after decades, checks of the numbers have shown that there is an error for numbers like 1986, which is in the form of inputs Given ... what to do?

I have put the verification work together which you should do.

  public static bool valid amount (string amount) {int posDecSep = amount.IndexOf (NumberFormatInfo.CurrentInfo.NumberDecimalSeparator); Int decimal places = amount. Long - posDecSep - 1; If (posDecSep & lt; 0) {decimalPlaces = 0; } If (decimal place & gt; 2) {// handle error with logic, or your validation returns incorrectly; Decimal DecAmount; If (Decimal try aspects (amount, outside of decimal)) {If (DCMount> = 0) {// positive} Other {// negative}} Returns correct; }  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -