/    Sign up×
Community /Pin to ProfileBookmark

multiple functions for a field

Hey all, I’m sure this is an easy one, but how would i nest multiple functions for an onChange event for a form field?

Here is the field:

<input name=”Amount” type=”text” id=”Amount” size=”15″ maxlength=”15″ onchange=”if (isNotEmpty(this))/>

Here are additional functions I need to perform:

(this.value = parseFloat(this.value).toFixed(2))

and

(isNumber(this))

and

(isLan6(this))

So is there a way I can have this one field use all these validations?

Thanks all!

[COLOR=darkred][B]..::Superfrappe::..[/B][/COLOR]

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@BhanuJun 03.2004 — call functions in one function

like

function MainFunction(Val){

a = isNotEmpty(Val);

a = isNotEmpty(Val);

a = isLan6(this);

}

<input name="Amount" type="text" id="Amount" size="15" maxlength="15" onchange="MainFunction(this)">

Bhanu
Copy linkTweet thisAlerts:
@SuperfrappeauthorJun 03.2004 — Bhanu, thanks for your reply. I tried out your code exactly as you posted it, and it gives me an error. Also, how would I incorporate this:


[COLOR=blue](this.value = parseFloat(this.value).toFixed(2))[/COLOR]


Here's the line that causes the error (in red below):


[COLOR=blue]// calls multiple functions for the amount field

function MainFunction(Val){

a = isNotEmpty(Val);

a = isNumber(Val);

[COLOR=darkred]a = isLan6(this);[/COLOR]

}[/COLOR]



...and here's the line I use:


[COLOR=blue]<input name="Amount" type="text" id="Amount" size="15" maxlength="15" onchange="MainFunction(this)" />[/color]


Thanks again for any help!
Copy linkTweet thisAlerts:
@BhanuJun 03.2004 — Change the last line in mainfunction as

a = isLan6(this); to a = isLan6(Val);

Bhanu
Copy linkTweet thisAlerts:
@SuperfrappeauthorJun 03.2004 — Thanks Bhanu, that worked. ALthough, I still need to work:


[color=blue]this.value = parseFloat(this.value).toFixed(2)[/color]


into the picture. This is very important to make the amount appear as money.

Thanks!
×

Success!

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

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

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