hi,
my form combo box has a problem. the textbox in my combo box dropdown-textbox list does not validate any error at all. when i am pressing the submit button. when the fields have no given value the script that i embed does not validate the error at all. please help.

heres my code:

<script language=javascript>
function validateForm(otheragency)
{
  if (document.otheragency.value =="")
	{alert('Please fill in all required fields');
	form.otheragency.disallowBlank();
	return true;}
	else if (document.otheragency.value=='agency')
	{form.otheragency.disallowBlank();
	return false;}
		
function validateForm(otherarea)
		
  if (document.otherarea.value =="")
	{alert('Please fill in all required fields');
	form.otherarea.disallowBlank();
	return true;}
	else if (document.otherarea.value=='area')
	{form.otherarea.disallowBlank();
	return false;}
	
function validateForm(othersubject)
	
  if (document.othersubject.value =="")
	{alert('Please fill in all required fields');
	form.othersubject.disallowBlank();
	return true;}
	else if (document.othersubject.value=='subject')
	{form.othersubject.disallowBlank();
	return false;}
}
<script>

got 24 views in my thread but no one even helped me.

If you are referring this with javascript, then you might want to try out this code to validate your fields.

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>Form Validation</title>
<style type="text/css">
/* <![CDATA[ */
html, body {
  background-color : #ccc;
  color : #405060;
  font : normal normal normal 95%/1.4 "Trebuchet MS", "Bernard MT Condensed", Tahoma, Verdana, Helvetica, Arial, sans-serif;
  min-height : 600px;
  text-align : center;
  height : auto;
  width : auto; }

body .m-title {
  background-color : #444;
  border-top : 2px solid #000;
  border-bottom : 2px solid #000;
  color : #757575;
  margin-top : 0;
  padding : .100em 1em .100em 1em;
  text-align : left;
  width : auto; }

div#main {
  background-color : #f0f0f0;
  margin : 0 auto;
  height : inherit !important;
  padding : 0;
  width : 100%; }

div.tube {
  border : 1px solid;
  background-color : inherit;
  height : inherit !important;
  clear : both;
  padding : 1em;
  margin : 0;
  overflow : hidden; }

  table {
  border-top : 1px solid;
  border-collapse;
  margin : 1em auto 0 auto;
  padding : 0;
  text-align : left;
  width : 100%; }

  td {
  font : normal normal normal 10pt Verdana, Arial, sans-serif;
  border-bottom : 1px solid;
  letter-spacing : 2px;
  color : #696969;
  line-height : 1.5;
  white-space : pre-wrap;
  vertical-align : middle;
  padding : .300em 1em .300em 1em; }
input[type="text"] {
  width : 90%;
  display : block; }

/* ]]> */
</style>
<script type="text/javascript">
// <![CDATA[
var validateForm;
var validNames, validPassword;
var errors;
var showErrors;

   showErrors = function( errors ) {
      msg = "\nPlease fill in the following field:\n";
    for ( var x = 0; x < errors.length; x++ ) {
      msg += (( x ) + 1 ) + ". " + errors[ x ] + "\n";
   } alert( msg );
};

   validNames = /[a-zA-Z\s]{3,10}/; // Allowing 3 to 10 non-digit charatcters in the field including white spaces.

   validPassword = /[a-zA-z\d]{6,12}/; // Allowing 6 to 12 characters in the field including digit's

validateForm = function( otheragency ) {
   errors = [ ]; // Used to store non-valid entrie's in the fields.
   with( otheragency ) {
      (( !validNames.test( field1.value )) ? errors[ errors.length ] = "Please provide a valid userame." : true );
      (( !validPassword.test( field2.value )) ? errors[ errors.length ] = "Please provide a valid password." : true );
      if ( errors.length > 0 ) {
      showErrors( errors );
      return false;
      }
   } alert( "Thank you, all field has been validated successfully." ); return true;
};
// ]]>
</script>
</head>
<body>
<div id="main">
<div id="content" class="tube">

<h2 class="m-title">Form Field Validation</h2>
<form id="myform" action="#" method="post" onsubmit="return validateForm( this );">
<table id="data" frame="void" rules="none" summary="Form Field Validation">
<tr>
<td><lable for="field1">username: <input type="text" id="field1" name="field1" value="" /></label></td>
</tr>
<tr>
<td><lable for="field2">password: <input type="password" id="field2" name="field2" value="" /></label></td>
</tr>
<tr>
<td><input type="submit" id="sbm" name="sbm" value="submit" /></td>
</tr>
</table>
</form>
</div>
</div>
</body>
</html>

If you have anymore questions, don't hesitate to asked back for a help.

hiii
instead of

if (document.otheragency.value =="")

use

if(form.otheragency.value=="")

do this at all the places....
n post back if it works...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.