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.