/    Sign up×
Community /Pin to ProfileBookmark

Numeric Range Validation PLEASE HELP ASAP

I am trying to update the code you see below with Numeric Validtion. This is a function that is called to verify a numeric field. But for my life I cant figure it out. I have attached the code below. All I am trying to do is update the code to allow a numeric range from 0 – 35000.. But still have the function do what it is already doing. Please help ASAP, I have to get this working by this afternoon. PLEASE HELP.. THANKS GUYS!

[code] function DrawNumericValidation(source, args){
var tb = source.id.split(“-“)[0];
var txt = document.getElementById(tb).value;
txt = txt.replace(/ /g,””);
document.getElementById(tb).value = txt;

args.IsValid = true;

if (txt == null || txt.length == 0) {
args.IsValid = true;
}
else {
for (var i = 0; i < txt.length; i++) {
var c = txt.charCodeAt(i);
if ((c < 48 || c > 57) && c != 46) {
args.IsValid = false;
}
}
} [/code]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@mrhooOct 06.2006 — var txt = document.getElementById(tb).value;

txt=txt.replace(/ +/g, '');

var n=parseInt(txt);

argsInvalid=(!n || n< 0 || n >35000);

if(!argsInvalid) document.getElementById(tb).value=n+'';
Copy linkTweet thisAlerts:
@gtaroauthorOct 06.2006 — MrWho thank you very much to the reply. Where do I place this code in my function?? Again thank you very much
×

Success!

Help @gtaro spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...