/    Sign up×
Community /Pin to ProfileBookmark

Use onSubmit-not sure how?

This is my form elements.

<table border>
<tr>
<td align=center>Windows:</td>
<td align=center><input type=”text” name=”winnum”>
<td align=center>Linux:</td>
<td align=center><input type=”text” name=”linuxnum” size=”5″ “>
</table>

Upon onSubmit, it should check that:
1.winnum and linuxnum is not null.If any of it is null, it will not submit
2.Submit will only occur if linuxnum + winnum is equals say 4.

How can I do this> Hope some one can help.
I am new at this.
Thanks a lot

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@StevilFeb 04.2004 — <form action="blah.html" method="post" onSubmit"return Validate(this)">

<table border>

<tr>

<td align=center>Windows:</td>

<td align=center><input type="text" name="winnum">

<td align=center>Linux:</td>

<td align=center><input type="text" name="linuxnum" size="5" ">

</table>

</form>

<script language="javascript">

function Validate(frm){

if(frm.winnum.value=="" || frm.linuxnum.value=="){

return true;

} else {

return false;

}

}

</script>


That should do what you want ?
Copy linkTweet thisAlerts:
@james_cwyauthorFeb 04.2004 — What about the second part:

2.Submit will only occur if linuxnum + winnum is equals say 4. (Need to check here also) if not equals 4 it will not submit

How can I do this?Thanks
Copy linkTweet thisAlerts:
@StevilFeb 04.2004 — <script language="javascript">

function Validate(frm){

//Checks Values Are There

if(frm.winnum.value=="" || frm.linuxnum.value=="){

return true;

}

//Checks Addition Of Values

if(frm.winnum.value + frm.linuxnum.value==4){

return true;

}

return false;

}

</script>


Sorry, missed that part ?
Copy linkTweet thisAlerts:
@james_cwyauthorFeb 04.2004 — Tried it but is not working

Shouldn't it be the other way around.

if both text is null, it will not submit-buit why return true?
Copy linkTweet thisAlerts:
@james_cwyauthorFeb 04.2004 — //Checks Addition Of Values

if(frm.winnum.value + frm.linuxnum.value==4){

return true;

}

return false;

}

Tried this part but not working, any ideas?
Copy linkTweet thisAlerts:
@james_cwyauthorFeb 04.2004 — This is the script :

function Validate(frm){

//this part OK

if(frm.winnum.value == "" || frm.linuxnum.value == ""){

alert ("Cannot be Null");

return false;

}

//not sure if this is right

if(frm.winnum.value + frm.linuxnum.value != 4){

alert ("Total number not equal to number of IPs");

return false;

}

//not sure if this is right

if(frm.winnum.value + frm.linuxnum.value == incount)

return true;

} //close function

Am I missing something or doing something wrong?

Hope someone can point it out.

I want it to return true only when frm.winnum.value + frm.linuxnum.value is equals say 4
×

Success!

Help @james_cwy 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.18,
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,
)...