Jump to content

[SOLVED] Validate Form


ainoy31

Recommended Posts

Hello-

 

I need help with validating my inputs on a form.  Is here my submit code.  I highlighted the two input names and the submit action.

 

<ul>
<li><?=$langContent[$section]['custom_range'];?>:  <?=$langContent[$section]['from'];?> <input type="text" class="DW100" id="f_date_c" [b]name="start_date"[/b] readonly="1" / value="" /><img src="/includes/calendar/ico_calendar.gif" align="top" width="30" height="22" id="f_trigger_c" style="cursor: pointer;" title="Date selector" onmouseover="this.style.background='white';" onmouseout="this.style.background=''" />  <?=$langContent[$section]['to'];?>  <input type="text" class="DW100" [b]name="end_date"[/b] id="f_date_c2" readonly="1" / value=""><img src="/includes/calendar/ico_calendar.gif" align="top" width="30" height="22" id="f_trigger_c2" style="cursor: pointer;" title="Date selector" onmouseover="this.style.background='white';" onmouseout="this.style.background=''" /> [b]<div class="ButtonContainer Inline"> <a class="Button Small" href="#" id="FormSubmit" onClick="validateDates(this.form);">[/b]<span><?=$langContent[$section]['view'];?></span></a></div><input type="hidden" name="ckey" value="<?=$customerID;?>"><input type="hidden" name="skey" value="<?=$accountID;?>" /></li>
</ul>

 

Here is my javascript for validation.

 


<script language="javascript" type="text/javascript">
<!--
	function validateDates(form)
	{
		ok = false;
		if(!document.usage.start_date.value.length == '')
		{
			ok = true;
		}
		if(!document.usage.end_date.value.length == '')
		{
			ok = true;
		}

		if(ok = true)
		{
			document.usage.submit();
		}
		else
		{
			alert("The start and the end dates need to be entered.");
		}
	}
//-->
</script>

 

Thanks for the help.  Ainoy

Link to comment
https://forums.phpfreaks.com/topic/119381-solved-validate-form/
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.