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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

javascript funtion issue

Status
Not open for further replies.

london01

Technical User
Jun 13, 2004
18
CA
hello everybody,

I have javascript that checks to validate emialfield and empty fields and these functions work. i like to include a popup, if the checks are successfull at the end.

i have the popup funcion thats tested and works but i'm not sure how to add the popup funtion within the formvalidation() funcion.

i tried adding an "else" statment at the end of with(ojbect) {} else(alert("alert"); but didn't wrok. any ideas?

sec. question is, how do i call a javascrip funciton in a php function. if i wanted to call formvalidation() in php function, whats the format?

function formvalidation(thisform)
{ with (form1)
{ if (emailvalidation(Email,"Illegal E-mail")==false) {Email.focus(); return false;};
if (emptyvalidation(field_three,"The textfield is empty")==false) {field_three.focus(); return false;};
} <<<<<<like to call a popup funciton if all checks are successful, how do i do this?
}
 
Well, since you're returning false upon both conditions, you could just have the statement as shown below. If it even reaches the alert function, that means your two calls to functions returned true, and therefore both fields were valid.

Hope this helps.

Code:
function formvalidation(thisform) {
    with (form1) {
        if (emailvalidation(Email,"Illegal E-mail")==false) {
            Email.focus();
            return false;
        }
        if (emptyvalidation(field_three,"The textfield is empty")==false) {
            field_three.focus();
            return false;
        }
        alert("All fields are valid!");
        return true;
    }
}

*cLFlaVA
----------------------------
A pirate walks into a bar with a huge ship's steering wheel down his pants.
The bartender asks, "Are you aware that you have a steering wheel down your pants?"
The pirate replies, "Arrrrr! It's driving me nuts!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top