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

Can anyone help with this? I hav 1

Status
Not open for further replies.

mikemackay

Programmer
Oct 22, 2001
4
GB
Can anyone help with this?

I have an image on an asp page which, on the 'onclick' event validates a text field (Password). After successfully validating the field, I want a particular layer to 'show' and the others to 'hide'. I am trying to do this without submitting the form

The problem is that the form validates OK but the 'MM_showHideLayers' does not work. If I leave out the 'return document.MM_returnValue;' the form validates by showing the alert, but then goes on to 'show' or 'hide' layers regardless.

Can I achieve form validation which stops the 'MM_showHideLayers' working if the validation picks up the textfield hasn't been completed properly and lets 'MM_showHideLayers' work if the textfield is completed properly, without submitting the form.

Help would be appreciated.

Code is below:


onClick="check_screen();return document.MM_returnValue;MM_showHideLayers('layer_reg_5','','hide','layer_reg_4','','hide','layer_reg_3','','hide','layer_reg_2','','show','layer_reg_1','','hide')" >

function check_screen(){

if (document.form1.Password.value == "")
{
alert("Please enter your password.");

return false;
}
else return true;
}
 
Code:
function check_screen(){

if (document.form1.Password.value == "") 
        {
        alert("Please enter your password.");
        
        //optional suggestion.
        document.form1.Password.focus();
        }
else {
        MM_showHideLayers(parameter list);
}

onclick is not interested in true or false, it just runs the javascript. Therefore your logic must make the decision to run MM_showHideLayers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top