/    Sign up×
Community /Pin to ProfileBookmark

how to call a javascript function when in multiple form

i have this code
function Check()
{
//If is not empty is true
return true
//else
return false

}

</script>

<form action=”TestSubmit.asp” method=”post” name=”f”>
<input type = “text” name=”TEST3″ value = “T1”><br>
<input type = “text” name=”TEST4″ value = “T2”><br>
<input type=”button” onClick=”this.form.action=’TestSubmit.asp’;this.form.submit()” value = “test3”>
<input type=”button” onClick=”this.form.action=’TestSubmit1.asp’;this.form.submit()” value = “test4”>
<input type=”button” onClick=”this.form.action=’http://localhost/cnafinal/ADMIN_TEST.asp?AID=731&SID=8849993935′;this.form.submit()” value = “Search”>
<input type=”button” onClick=”this.form.action=’http://www.yahoo.com’;return Check()” value = “test5” id=button1 name=button1>
</form>

this is only sample piece of code i want to test, how can i validate the form when i click on the button test5, if validations is true then go to the [url]http://www.yahoo.com[/url] else
remain intact, can anyone show me an example

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@verybrightstarauthorApr 10.2003 — I would like to validate the below textbox for TEST3 is it like this

i have this code

function Check()

{

//If is not empty is true

if(document.f.TEST3.value != "")

{

return true

}

//else

return false

}


</script>

<form action="TestSubmit.asp" method="post" name="f">

<input type = "text" name="TEST3" value = "T1"><br>

<input type = "text" name="TEST4" value = "T2"><br>

<input type="button" onClick="this.form.action='TestSubmit.asp';this.form.submit()" value = "test3">

<input type="button" onClick="this.form.action='TestSubmit1.asp';this.form.submit()" value = "test4">

<input type="button" onClick="this.form.action='http://localhost/cnafinal/ADMIN_TEST.asp?AID=731&SID=8849993935';this.form.submit()" value = "Search">

<input type="button" onClick="this.form.action='http://www.yahoo.com';return Check()" value = "test5" id=button1 name=button1>

</form>
×

Success!

Help @verybrightstar 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.2,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

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