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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.