Hi !
Who could help me with a javascript ?
What I need:
We have pages, where a user could input amounts.
These amounts could only be numbers (e.g. 100) with OR without an "M" (for million) or an "T" (for thousand):
e.g. 100 (hundred) , 100M (one hundred million), 100T (one hundred thousand) and so on.
- I need a validation script (which can be used for onKeyPress and onBlur) which ONLY accepts ".1234567890MT".
- This script has also to check whether the user puts in a "," . If so, the script has to replace this with an "."
- Only ONE "." is allowed, this means, if the user tries to put in: "100.000.000", the script should take out the last ".", because ONLY ONE "." is allowed.
-It should always capitalize the "m" or "t", whgen a user put that in. e.g. : 100m -> 100M
At least, there should be a parameter which thell the function, in the user is allowed to put in a NEGATIVE value or NOT.
e.g.: function_xy(notNegative)...
if notNegatibe == true -> no negative values are allowed, the script should also not allow to put in a "-" before the number, M or T is allowed
if notNegative == false -> the user could input 0-9, negative values are allowed, the user can put in a "-" before the number, M or T is allowed
The first function should be e.g. validOnKeyPress(notNegative);
The second function should be e.g. validFieldOnBlur(notNegative);
I hope, this is not to much![Smile :) :)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
Could somebody help me here ?
This would be GREAT !!!
regards
Michael
Who could help me with a javascript ?
What I need:
We have pages, where a user could input amounts.
These amounts could only be numbers (e.g. 100) with OR without an "M" (for million) or an "T" (for thousand):
e.g. 100 (hundred) , 100M (one hundred million), 100T (one hundred thousand) and so on.
- I need a validation script (which can be used for onKeyPress and onBlur) which ONLY accepts ".1234567890MT".
- This script has also to check whether the user puts in a "," . If so, the script has to replace this with an "."
- Only ONE "." is allowed, this means, if the user tries to put in: "100.000.000", the script should take out the last ".", because ONLY ONE "." is allowed.
-It should always capitalize the "m" or "t", whgen a user put that in. e.g. : 100m -> 100M
At least, there should be a parameter which thell the function, in the user is allowed to put in a NEGATIVE value or NOT.
e.g.: function_xy(notNegative)...
if notNegatibe == true -> no negative values are allowed, the script should also not allow to put in a "-" before the number, M or T is allowed
if notNegative == false -> the user could input 0-9, negative values are allowed, the user can put in a "-" before the number, M or T is allowed
The first function should be e.g. validOnKeyPress(notNegative);
The second function should be e.g. validFieldOnBlur(notNegative);
I hope, this is not to much
Could somebody help me here ?
This would be GREAT !!!
regards
Michael