dimanche 5 juillet 2020

How to write if condition to check numbers greater than or less than in php?

I have one input field where user will add numbers and in next label it will display that numbers in words. Basically user will input amount in number format and it will display in word format.And i have some conditions to show amount in words.

First condition is Amount should not greater than 10 digits.

Second condition is user can add money in decimal format.

e.g : this is 1000000000.90 Allow (10 digits and then decimal point)

e.g : this is 10000000000.90 Not Allow (decimal point after eleven digit)

So basically Amount length can go upto 13 digits with decimal point.

Without decimal Point it should be upto 10

For this I write below condition :

if(amount.length > 13){
   return 'please enter less amount';
}
if(amount.length > 10 && amount.includes('.') === false){
 return 'please enter less amount';
}

When i enter 11 digits and then decimal point 10000000000.0 it shows me amount in words but i want here to display error message because before decimal point there should be only 10 digits are allowed

So. Basically I want condition for allowd amount with decimal 13 digits and without decimal 1 digits only.please help me to solve this scenario. thanks in advance.

Aucun commentaire:

Enregistrer un commentaire