My idea is something like this but I dont know the correct code
if (mystring.matches(\"[0-9.]+\")){
//do something here
}else{
//do something here
}
<
Use the below RegEx its solve your proble
allow 2 decimal places ( e.g 0.00 to 9.99)
^[0-9]{1}[.]{1}[0-9]{2}$
This RegEx states:
1. ^ means the string must start with this.
2. [0-9] accept 0 to 9 digit.
3. {1} number length is one.
4. [.] accept next character dot.
5. [0-9] accept 0 to 9 digit.
6. {2} number length is one.
allow 1 decimal places ( e.g 0.0 to 9.9)
^[0-9]{1}[.]{1}[0-9]{1}$
This RegEx states:
1. ^ means the string must start with this.
2. [0-9] accept 0 to 9 digit.
3. {1} number length is one.
4. [.] accept next character dot.
5. [0-9] accept 0 to 9 digit.
6. {1} number length is one.