469,339 Members | 8,437 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,339 developers. It's quick & easy.

multipe steps in button click

can someone help to get this working ?
<input type="submit" value="Submit"
onclick=" if (document.forms[ 0 ].password == ''){
alert('please enter a password')}
elseif (document.forms[ 0 ].password != ''){
alert('please be patient while your history is loading')}"
>

Aug 1 '06 #1
1 1210

Jon Paal wrote:
can someone help to get this working ?
<input type="submit" value="Submit"
onclick=" if (document.forms[ 0 ].password == ''){
alert('please enter a password')}
elseif (document.forms[ 0 ].password != ''){
alert('please be patient while your history is loading')}"
>
It would be better if you've handled the submission on the form element
instead:

<form action = "yourpage.ext" onsubmit = "return checkMyForm(this)">

In your javascript, you can then define a function to do what you
wanted in the following example:

function checkMyForm(myForm)
{
if(myForm.elements["password"].value == "")
{
alert("please enter a password");
return false;
}
else
{
alert("please be patient...");
return true;
}
}

The thing you were missing was the 'value' property. Note that
returning false will not submit your form and returning true will.

Aug 1 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Niks | last post: by
11 posts views Thread by CW | last post: by
3 posts views Thread by Imran Aziz | last post: by
reply views Thread by Bill Gauvey | last post: by
reply views Thread by U S Contractors Offering Service A Non-profit | last post: by
9 posts views Thread by Jonathan Wood | last post: by
1 post views Thread by CARIGAR | last post: by
1 post views Thread by haryvincent176 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.