SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2003
    Location
    l'Europe
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    validation of form with layers

    Hi,

    I've tested a very good validation script called(fValidate ). Now, I want it to implement into a php-form which has 2 layers. Layers are called with following code:

    Code:
    function showLayer(layer)
    {
    	strHidden = ( !document.layers ) ? "hidden" : "hide";
    	strVisible = ( !document.layers ) ? "visible" : "show";
    
    	if( document.layers ){
    		lyrForm1 = document.idForm1;
    		lyrForm2 = document.idForm2;
    
    	} else if( document.getElementById ){
    
    		lyrForm1 = document.getElementById("idForm1").style;
    		lyrForm2 = document.getElementById("idForm2").style;
    
    	} else if( document.all ){
    
    		lyrForm1 = document.all["idForm1"].style;
    		lyrForm2 = document.all["idForm2"].style;
    	}
    
    	lyrForm1.visibility = (layer == "idForm1") ? strVisible : strHidden;
    	lyrForm2.visibility = (layer == "idForm2") ? strVisible : strHidden;
    
    	return false;
    }
    Code:
    [<A HREF="javascript:void(0);" onClick="return showLayer('idForm1');">page 1</A>]
    [<A HREF="javascript:void(0);" onClick="return showLayer('idForm2');">page 2</A>]
    .

    When I submit the form, the validation script alerts the first "wrong" field which is on layer 1 (invisible because the submit button is on layer 2). Normally it goes to that wrong field, but instead it submits the form...

    Does anyone has any experience with validation of layered forms?

    There is also the possibility of making a custom validation function. I could make use of it, but then... how does javascript know on which layer the wrong field is/was...?

    Any suggestions are welcome,

    Sincerly,

    Ann

  2. #2
    SitePoint Enthusiast
    Join Date
    Feb 2003
    Location
    l'Europe
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I've made following work-around:

    There are three functions (date, decimalr and select) that I use on such forms. Therefore, I made three "new" custom functions (same as original, but named "div-..." and with one more parameter, indicating the layer where the "wrong" field is on.

    In the custom function, where the error dialog is being called, I first make the right layer visible with the existing function (showlayer, see previous post)...

    Maybe it's not the best solution, but it helped me.
    The fValidate validation script is really the best of it's kind in what I've seen on the web... beautiful!

    Ann,


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •