Jump to content

Conflicting scripts making form not validate.


deansaddigh

Recommended Posts

I have a enquiry from that is not validating (pop up boxes are meant to come up)

Now that i have included this code into my headerlinks.php

 

<script src="js/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
        $(document).ready(function() {

            $(".signin").click(function(e) {
                e.preventDefault();
                $("fieldset#signin_menu").toggle();
                $(".signin").toggleClass("menu-open");
            });

            $("fieldset#signin_menu").mouseup(function() {
                return false
            });
            $(document).mouseup(function(e) {
                if($(e.target).parent("a.signin").length==0) {
                    $(".signin").removeClass("menu-open");
                    $("fieldset#signin_menu").hide();
                }
            });            

        });
</script>

 

This code basically makes a pop out box for my sign in.

 

this can be seen here http://www.languageschoolsuk.com/course_enquiry.php

 

At the top right where it says login. basically makes a box pop out when you click where you can sign in.

 

However you will also notice that on the same page the course enquiry form below will send even with nothing in it, Before i had the above script it used to validate by little pop up boxes comming up.

 

Heres the enqury page code where im using some js

 

<script type="text/javascript"  src="js/mootools-1.2.4-core.js"></script>
<script type="text/javascript"  src="js/mootools-1.2.4.4-more.js"></script>



<script type="text/javascript" src="includes/formcheck/lang/en.js"> </script>
<script type="text/javascript" src="includes/formcheck/formcheck.js"> </script>
<script type="text/javascript">
    window.addEvent('domready', function(){
        new FormCheck('two');
    });
</script>

 

Can you see anyting on headerlink page that stops this form from validating because as i said before it was.

 

Thanks in advance

 

Unless you use a function handler to handle the loading of javascripts, I think that you can have only one javascript run at at time (If i'm understanding your problem).

 

If so try adding this to your header, and use it to call your mulitple javascripts (remember to place them in the sequence that you want them to fire off in).

 


<script type="text/javascript">
	//place local js code here

	function init()
	{//a test function - replace with your cool code!
		alert("I'm init!");  //pun alert!
	}

	//window.onload=init;  //run init onload - replace with your function!
	addOnload(init); //with addOnload() we can add as many functions as we wish to window.onload (one by one)!
</script>

Mixing mootools and jquery in my book fits in the bad category. I suggest sticking with just one js framework. However if you really must (can't think of any valid reason) there are ways to work around this. Take a look at the noconflict method in jquery and the document.id functionality in mootools.

Thanks guys, Im new to java script so pardon my ignorance, one question i wanted to ask is do

<script type="text/javascript">
        $(document).ready(function() {

            $(".signin").click(function(e) {
                e.preventDefault();
                $("fieldset#signin_menu").toggle();
                $(".signin").toggleClass("menu-open");
            });

            $("fieldset#signin_menu").mouseup(function() {
                return false
            });
            $(document).mouseup(function(e) {
                if($(e.target).parent("a.signin").length==0) {
                    $(".signin").removeClass("menu-open");
                    $("fieldset#signin_menu").hide();
                }
            });            

        });
</script>

have to be in the head of a document

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.