Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Msgbox from form help

Status
Not open for further replies.

Terminus

IS-IT--Management
Jul 16, 2003
31
0
0
GB
Hi there, i have no knowledge of java script but i need to edit it and i cant get it working can some1 help me?

I have a form which checks form data (that both passwords match) what i need to do is check that the user haas entered an email and password that isnt blank and if it is request via msg box that they enter the data

for the password match script ive got:

function VerifyData()
{
if (document.frmUser.Password.value != document.frmUser.VerifyPassword.value)
{
alert ("Your passwords do not match - please reenter");
return false;
}
else
return true;
}

Can anyone help me add to this?

Many thanks

Terminus
 
Code:
function formValidate(theForm){
 if (theForm.email.value = ""){
      alert("Please enter a valid Email Address");
      theForm.email.focus();
      return (false);}
 if (theForm.Password.value = ""){
      alert("Please enter a valid Password");
      theForm.Password.focus();
      return (false);}
}

Then, add this to your form tag on your HTML page:

onsubmit="return formValidate(this)"

There's always a better way. The fun is trying to find it!
 
Make sure you use == for evaluating instead of =
Code:
function formValidate(theForm){
 if (theForm.email.value == ""){
      alert("Please enter a valid Email Address");
      theForm.email.focus();
      return (false);}
 if (theForm.Password.value == ""){
      alert("Please enter a valid Password");
      theForm.Password.focus();
      return (false);}
}

Adam
while(ignorance){perpetuate(violence,fear,hatred);life=life-1};
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top