Jump to content

Hidden Fields Validation


ainoy31

Recommended Posts

Yeah.  I tried what you have stated and it does not seem to work.

 

Here are the hidden fields.


$skipCovCheckPage = "/customers/sales/productGroups.php?customer_id=12"
<form name="dataForm" method="POST" action="<?php echo $skipCovCheckPage; ?>">
<input type="hidden" name="city" value="<?=$data['city'];?>">
<input type="hidden" name="state" value="<?=$data['state'];?>">
<input type="hidden" name="zip_code"  value="<?=$data['zip_code'];?>">
<input type="hidden" name="phone_1" value="<?=$data['phone_1'];?>">
<input type="hidden" name="region_id" value="<?=$data['region_id'];?>">
<input type="hidden" name="saleType" value="<?=$data['saleType'];?>">

<div class="ButtonContainer"> 
<a class="Button Primary" href="#" id="FormSubmit" onClick="return validateService();"><span>Continue</span></a>
</div>
</form>

 

The javascript:

function validateService()
{
if(document.dataForm.elements['address_1'].value == "")
{
alert("Street Name is invalid.");
return false;
}
if(document.dataForm.elements['city'].value == "")
{
alert("City is invalid.");
return false;
}
if(document.dataForm.elements['state'].value == "")
{
alert("State is invalid.");
return false;
}
if(document.dataForm.elements['zip_code'].value == "")
{
alert("Postal Code is invalid.");
return false;
}
if(document.dataForm.elements['phone_1'].value == "")
{
alert("Phone 1 is invalid.");
return false;
}
document.dataForm.action = '<?php echo $skipCovCheckPage; ?>';
document.dataForm.submit();
}

 

The alert message will popup even though the street name field is populated.  Much appreciation. AM

 

 

its working for me with this test code

 

 

<script>
function CheckForm()
{
if(document.getElementById('CM').value=='')
{
	alert('THERE IS NO VALUE');
}
else
{
	alert("The Value of the input is "+ document.getElementById('CM').value);
}
}
</script>



<form action='' method='post'>

<input type='hidden' value='CrackerMonkey' name='CM' id='CM' />


<input type='submit' value='submit' onmousedown='CheckForm();' />
</form>

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.