/    Sign up×
Community /Pin to ProfileBookmark

Help with default value

Hey guys,

I am needing a script that will make a field equal 0.00 if there is no input. If there is input, then it no longer equals 0.00 and is whatever they type in. I can’t figure it out. Here is what I’ve tried, but none of it works——

[CODE]
var a = this.getField(“LO”);
if(a == “”)
event.value = 0.00
else if(a == //* this is where I don’t know what to put
[/CODE]

and then I’ve tried this——

[CODE]
var a = this.getField(“LO”);
if(a==””) {a = 0;}
[/CODE]

Any help would be appreciated! Thanks guys

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@KorNov 02.2007 — What is [B]a[/B]? A value? An object?
Copy linkTweet thisAlerts:
@FangNov 02.2007 — Does this help<input type="text" value="0.00" onfocus="this.value='';" onblur="if(this.value==''){this.value=this.defaultValue;}">
Copy linkTweet thisAlerts:
@dnormanauthorNov 02.2007 — the "a" is the variable for the field name ("LO") i am needing validated, i guess you could say. If it helps any, it is for a pdf I am using in Acrobat Pro 6. I work for an insurance company and there is a form our agents use to calculate premiums and with the calculation script i am using, if a field is blank, then the script doesn't work. And not all of our agents know much about computers so I want the field to be filled in with a 0.00 automatically if they do not put any information in. (because the fields are optional and might not have any input). The script cant have any html tags or anything, just simple regexp's. Thanks guys ?
Copy linkTweet thisAlerts:
@dnormanauthorNov 02.2007 — "[B]a[/B]" is a value......
×

Success!

Help @dnorman 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 5.20,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...