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
}
<
If you want to -> make sure it's a number AND has only one decimal <- try this RegEx instead:
if(mystring.matches("^[0-9]*\\.?[0-9]*$")) {
// Do something
}
else {
// Do something else
}
This RegEx states:
Note that bullet point #2 is to catch someone entering ".02" for example.
If that is not valid make the RegEx: "^[0-9]+\\.?[0-9]*$"