Jump to content

jQuery Help


dc_jt

Recommended Posts

Hi

 

I have got a page which contains a form. The form uses jquery inline validation from here: http://www.position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/

 

Within my page, I have got a button which uses a jquery function to load a form in from an external page which replaces the current form. However, once this is loaded, the validation stops working! Any idea why?

 

Please see my code below:

 

Original page with form:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>
<meta name="description" content=""/>
<meta name="Keywords" content=""/>
<meta name="robots" content="index"/>
<meta name="revisit-after" content="1 days"/>
<meta name="author" content=""/>
<meta name="copyright" content=""/>

<link rel="stylesheet" href="css/validationEngine.jquery.css" type="text/css" media="screen" charset="utf-8" />

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript"></script>
<script src="js/jquery.validationEngine-en.js" type="text/javascript"></script>
<script src="js/jquery.validationEngine.js" type="text/javascript"></script>

<script src="js/postcode-anywhere.js" type="text/javascript"></script>
<script>
	jQuery.noConflict();

      	jQuery(document).ready(function() {
      
       	jQuery("#formID").validationEngine()
       	
        });
        
        	function example_ajax_request(divId, url) {

    jQuery('#'+divId).load(url, "",
        function(responseText, textStatus, XMLHttpRequest) {
            if(textStatus == 'error') {
                jQuery('#'+divId).html('<p>There was an error making the AJAX request</p>');
            }
        }
    );
   
}

</script>
</head>
<body>

<div id="step2-form">

<form id="formID" name=formID" method="post" action="<?=$_SERVER['PHP_SELF'];?>">
<input type="hidden" id="stage_complete" name="stage_complete" value="2" />

echo "<input name=\"edit\" type=\"button\" value=\"edit\" onclick=\"example_ajax_request('step2-form', 'ajax/updateStep2Form.php?iAddressId=".$oAddress->addressId."&iCustomerId=".$_SESSION['application']->customerId."');\">";

<label for="address1">
	<span>Address 1<em>*</em></span>
	<span>
	<input name="address1" type="text" class="validate[required,length[0,100]] text-input" id="address1" value="<?=$_POST['address1'] ? $_POST['address1'] : "";?>" />
	</span>
	</label>

			</form>

			</div>

 

This is the external page (updateStage2.php):

 


<div id="step2-form">

<form id="formID" name=formID" method="post" action="<?=$_SERVER['PHP_SELF'];?>">
<input type="hidden" id="stage_complete" name="stage_complete" value="2" />

echo "<input name=\"edit\" type=\"button\" value=\"edit\" onclick=\"example_ajax_request('step2-form', 'ajax/updateStep2Form.php?iAddressId=".$oAddress->addressId."&iCustomerId=".$_GET['iCustomerId']."');\">";

<label for="address1">
	<span>Address 1<em>*</em></span>
	<span>
	<input name="address1" type="text" class="validate[required,length[0,100]] text-input" id="address1" value="<?=$_POST['address1'] ? $_POST['address1'] : "";?>" />
	</span>
	</label>

</form>

			</div>

 

There must be a conflict somewhere because the validation just doesnt work at all once I have loaded in the external page into the <div> called step2-form. Does anyone know why? I have been trying various things for hours! Could it be because of the validationEngine function being called?

 

Any help will be greatly appreciated.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/188235-jquery-help/
Share on other sites

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.