Solved

Yaromat Check Form behavior not validating

Posted on 2008-10-18
2
911 Views
Last Modified: 2010-04-21
Hi Experts

I have been using the Yaromat Dreamweaver cjeck form behaviour successfully for a number of years, however I a webpage (see code below) where the behaviour will not validate and the user is able to submit the form leaving blank fields.  I have tried to remove the behaviour, tidy up the code etc etc etc but I cannot get it to work for whatever reason.

Can anyone advise on what might be the problem?

Thanks

Grant
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/camsmith.asp" -->
<%
Dim MM_editAction
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
  MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If
 
' boolean to abort record edit
Dim MM_abortEdit
MM_abortEdit = false
%>
<%
' IIf implementation
Function MM_IIf(condition, ifTrue, ifFalse)
  If condition = "" Then
    MM_IIf = ifFalse
  Else
    MM_IIf = ifTrue
  End If
End Function
%>
<%
If (CStr(Request("MM_insert")) = "form1") Then
  If (Not MM_abortEdit) Then
    ' execute the insert
    Dim MM_editCmd
 
    Set MM_editCmd = Server.CreateObject ("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_camsmith_STRING
    MM_editCmd.CommandText = "INSERT INTO dbo.PropertyMatching (mClientName, mClientAddress1, mClientAddress2, mClientTown, mClientPostcode, mClientTelHome, mClientTelWork, mClientTelMobile, mClientEmail, mMinPrice, mMaxPrice, mMinBeds, mMinPublicRooms, mTown, mBuildingType) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" 
    MM_editCmd.Prepared = true
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 201, 1, 30, Request.Form("mClientName")) ' adLongVarChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 201, 1, 60, Request.Form("mClientAddress1")) ' adLongVarChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 201, 1, 60, Request.Form("mClientAddress2")) ' adLongVarChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 201, 1, 60, Request.Form("mClientTown")) ' adLongVarChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 201, 1, 10, Request.Form("mClientPostcode")) ' adLongVarChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param6", 201, 1, 20, Request.Form("mClientTelHome")) ' adLongVarChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param7", 201, 1, 20, Request.Form("mClientTelWork")) ' adLongVarChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param8", 201, 1, 20, Request.Form("mClientTelMobile")) ' adLongVarChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param9", 201, 1, 100, Request.Form("mClientEmail")) ' adLongVarChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param10", 5, 1, -1, MM_IIF(Request.Form("mMinPrice"), Request.Form("mMinPrice"), null)) ' adDouble
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param11", 5, 1, -1, MM_IIF(Request.Form("mMaxPrice"), Request.Form("mMaxPrice"), null)) ' adDouble
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param12", 5, 1, -1, MM_IIF(Request.Form("mMinBeds"), Request.Form("mMinBeds"), null)) ' adDouble
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param13", 5, 1, -1, MM_IIF(Request.Form("mMinPublicRooms"), Request.Form("mMinPublicRooms"), null)) ' adDouble
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param14", 201, 1, 25, Request.Form("mTown")) ' adLongVarChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param15", 201, 1, 20, Request.Form("mBuildingType")) ' adLongVarChar
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close
 
    ' append the query string to the redirect URL
    Dim MM_editRedirectUrl
    MM_editRedirectUrl = "../index.asp"
    If (Request.QueryString <> "") Then
      If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
        MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
      Else
        MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
      End If
    End If
    Response.Redirect(MM_editRedirectUrl)
  End If
End If
%>
 
<%
Dim propertytypes
Dim propertytypes_cmd
Dim propertytypes_numRows
 
Set propertytypes_cmd = Server.CreateObject ("ADODB.Command")
propertytypes_cmd.ActiveConnection = MM_camsmith_STRING
propertytypes_cmd.CommandText = "SELECT * FROM dbo.propertytypesmaster ORDER BY ptmastype" 
propertytypes_cmd.Prepared = true
 
Set propertytypes = propertytypes_cmd.Execute
propertytypes_numRows = 0
%><%
Dim towns
Dim towns_cmd
Dim towns_numRows
 
Set towns_cmd = Server.CreateObject ("ADODB.Command")
towns_cmd.ActiveConnection = MM_camsmith_STRING
towns_cmd.CommandText = "SELECT distinct pTown FROM dbo.Property ORDER BY pTown" 
towns_cmd.Prepared = true
 
Set towns = towns_cmd.Execute
towns_numRows = 0
%>
<% Session.LCID = 2057 %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="keywords" content="Solicitors, Estate Agents, Cullen Kilshaw, Cullen, Kilshaw, Galashiels, Scotland, Scottish Borders, Borders, property, buying, selling, letting, new build, legal services, Peebles, Melrose, Eyemouth, legal, home, plots, commercial, rental">
<meta name="description" content="Cullen Kilshaw Solicitors & Estate Agents">
<meta name="author" content="Cullen Kilshaw Solicitors & Estate Agents">
<meta name="copyright" content="&copy; 2008 Cullen Kilshaw Solicitors & Estate Agents">
<link rel="shortcut icon" href="/favicon.ico">
<title>Cullen Kilshaw Solicitors &amp; Estate Agents - Buying Property in the Scottish Borders</title>
<link href="generalstyles.css" rel="stylesheet" type="text/css" />
 
<!-- End of object/array definitions, beginning of generic functions -->
<script language="JavaScript">
<!--
}
 
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
 
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
 
function YY_checkform() { //v4.66
//copyright (c)1998,2002 Yaromat.com
  var args = YY_checkform.arguments; var myDot=true; var myV=''; var myErr='';var addErr=false;var myReq;
  for (var i=1; i<args.length;i=i+4){
    if (args[i+1].charAt(0)=='#'){myReq=true; args[i+1]=args[i+1].substring(1);}else{myReq=false}
    var myObj = MM_findObj(args[i].replace(/\[\d+\]/ig,""));
    myV=myObj.value;
    if (myObj.type=='text'||myObj.type=='password'||myObj.type=='hidden'){
      if (myReq&&myObj.value.length==0){addErr=true}
      if ((myV.length>0)&&(args[i+2]==1)){ //fromto
        var myMa=args[i+1].split('_');if(isNaN(myV)||myV<myMa[0]/1||myV > myMa[1]/1){addErr=true}
      } else if ((myV.length>0)&&(args[i+2]==2)){
          var rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-z]{2,4}$");if(!rx.test(myV))addErr=true;
      } else if ((myV.length>0)&&(args[i+2]==3)){ // date
        var myMa=args[i+1].split("#"); var myAt=myV.match(myMa[0]);
        if(myAt){
          var myD=(myAt[myMa[1]])?myAt[myMa[1]]:1; var myM=myAt[myMa[2]]-1; var myY=myAt[myMa[3]];
          var myDate=new Date(myY,myM,myD);
          if(myDate.getFullYear()!=myY||myDate.getDate()!=myD||myDate.getMonth()!=myM){addErr=true};
        }else{addErr=true}
      } else if ((myV.length>0)&&(args[i+2]==4)){ // time
        var myMa=args[i+1].split("#"); var myAt=myV.match(myMa[0]);if(!myAt){addErr=true}
      } else if (myV.length>0&&args[i+2]==5){ // check this 2
            var myObj1 = MM_findObj(args[i+1].replace(/\[\d+\]/ig,""));
            if(myObj1.length)myObj1=myObj1[args[i+1].replace(/(.*\[)|(\].*)/ig,"")];
            if(!myObj1.checked){addErr=true}
      } else if (myV.length>0&&args[i+2]==6){ // the same
            var myObj1 = MM_findObj(args[i+1]);
            if(myV!=myObj1.value){addErr=true}
      }
    } else
    if (!myObj.type&&myObj.length>0&&myObj[0].type=='radio'){
          var myTest = args[i].match(/(.*)\[(\d+)\].*/i);
          var myObj1=(myObj.length>1)?myObj[myTest[2]]:myObj;
      if (args[i+2]==1&&myObj1&&myObj1.checked&&MM_findObj(args[i+1]).value.length/1==0){addErr=true}
      if (args[i+2]==2){
        var myDot=false;
        for(var j=0;j<myObj.length;j++){myDot=myDot||myObj[j].checked}
        if(!myDot){myErr+='* ' +args[i+3]+'\n'}
      }
    } else if (myObj.type=='checkbox'){
      if(args[i+2]==1&&myObj.checked==false){addErr=true}
      if(args[i+2]==2&&myObj.checked&&MM_findObj(args[i+1]).value.length/1==0){addErr=true}
    } else if (myObj.type=='select-one'||myObj.type=='select-multiple'){
      if(args[i+2]==1&&myObj.selectedIndex/1==0){addErr=true}
    }else if (myObj.type=='textarea'){
      if(myV.length<args[i+1]){addErr=true}
    }
    if (addErr){myErr+='* '+args[i+3]+'\n'; addErr=false}
  }
  if (myErr!=''){alert('The required information is incomplete or contains errors:\t\t\t\t\t\n\n'+myErr)}
  document.MM_returnValue = (myErr=='');
}
//-->
</script>
 
<link href="includes/menu_style.css" rel="stylesheet" type="text/css" />
<script src="../Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
 
<style type="text/css">
<!--
.style1 {color: #FF0000}
-->
</style>
</head>
<body>
 
<div id="outerwrapper">
<div id="pagewrapper">
<div class="pageinfoleft"> <img src="graphics/ck_logo_square_property.jpg" alt="Cullen Kilshaw logo" hspace="5" vspace="0" /> HOMES
  BY EMAIL &nbsp;|
  CULLEN KILSHAW Solicitors &amp; Estate
  Agents</div>
<div class="pageinfo">
     <a href="../cgi-bin/parser.pl">TEXT ONLY</a>&nbsp; |   &nbsp;<a href="../index.asp" title="Homepage">HOMEPAGE</a>&nbsp; | &nbsp;<a href="contactcullenkilshaw.asp" title="Contact Cullen Kilshaw">CONTACT
     CULLEN KILSHAW </a> </div>
  <table width="860" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td align="left" valign="top"><!--#include file="includes/mainnav_ck.asp" --></td>
    </tr>
    <tr>
      <td width="860" height="0" align="left" valign="top"><div id="feature_propertyregister">
		  <h1 class="indent">HOMES by EMAIL</h1>
		  <h2 class="indent"> Join our Mailing List</h2>
		  <br />
<h2>Be the first to know ...  </h2>
        <br />
 
        <p>New properties are added to our website on a daily basis.  Be the
          first to know about properties that match your requirements by registering
          for homes by email.
          <br />
          <br />
 </p>
        <p>
            <span class="redshadow">1</span> Simply complete the registration
            form with your details and your property requirements. On receipt
            of your details, your information will be added to our property systems.&nbsp;&nbsp;<br />
              <br />
               <span class="redshadow">2</span> When a new property which matches your requirements is  added to our property systems, an automatic email notification will be sent to  you.<br />
              <br />
Your registration will remain active for a  period of 30 days, should you wish to change your property requirements  or remove your details from our systems, please contact our offices.<br />
            </p>
            </div>
      <div id="logo">
          <a href="../index.asp" title="Go to Cullen Kilshaw's Homepage" ><img src="graphics/cullenkilshaw_logo.gif" alt="Cullen Kilshaw Solicitors &amp; Estate Agents logo" width="279" height="47" border="0" /></a><br />
        </div>    <div id="introductiontext">
          <p>&nbsp;</p>
          <p>Submit  the request form below to register for homes by email.        </p>
        </div>
        <div id="presale_header">
        <h1>HOMES BY EMAIL | REGISTRATION</h1>
        <table width="520" border="0" cellspacing="0" cellpadding="2">
  <tr>
    <td valign="top"><form action="<%=MM_editAction%>" method="POST" name="form1" id="form1" onsubmit="YY_checkform('form1','mClientName','#q','0','Please enter your name');return document.MM_returnValue">
           <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>    </tr>
  
  <tr>
    <td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
      
      <tr>
        <td height="40" colspan="2"><h2>YOUR DETAILS</h2><p> *Required Information</p></td>
        </tr>
      
      <tr>
        <td colspan="2"><table width="100%" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td width="38%" height="28"><p>Name:*</p></td>
            <td width="62%"><p>
              <input name="mClientName" type="text" id="mClientName" maxlength="30" />
            </p></td>
          </tr>
          <tr>
            <td height="28"><p>Street No/House Name:</p></td>
            <td><input name="mClientAddress1" type="text" id="mClientAddress1" maxlength="60" /></td>
          </tr>
          <tr>
            <td height="28"><p>Street Name:</p></td>
            <td><input name="mClientAddress2" type="text" id="mClientAddress2" maxlength="60" /></td>
          </tr>
          <tr>
            <td height="28"><p>Town:</p></td>
            <td><input name="mClientTown" type="text" id="mClientTown" maxlength="60" /></td>
          </tr>
          <tr>
            <td height="28"><p>Postcode:</p></td>
            <td><input name="mClientPostcode" type="text" id="mClientPostcode" size="15" maxlength="10" /></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td height="28"><p>Telephone No. (Home):</p></td>
            <td><input name="mClientTelHome" type="text" id="mClientTelHome" size="20" maxlength="20" /></td>
          </tr>
          <tr>
            <td height="28"><p>Telephone No. (Work):</p></td>
            <td><input name="mClientTelWork" type="text" id="mClientTelWork" size="20" maxlength="20" /></td>
          </tr>
          <tr>
            <td height="28"><p>Telephone No. (Mobile):</p></td>
            <td><input name="mClientTelMobile" type="text" id="mClientTelMobile" size="20" maxlength="20" /></td>
          </tr>
          <tr>
            <td height="28"><p>Email Address:*</p></td>
            <td><input name="mClientEmail" type="text" id="mClientEmail" size="30" maxlength="100" /></td>
          </tr>
          
 
        </table></td>
        </tr>
      <tr>
        <td colspan="2">&nbsp;</td>
      </tr>
      <tr>
        <td height="40" colspan="2"><h2>YOUR PROPERTY REQUIRMENTS</h2></td>
        </tr>
      
      
      <tr>
        <td width="37%" height="28"><p>Minimum Price: </p></td>
        <td width="63%"><select name="mMinPrice" id="mMinPrice">
            <option value="0">No Min Price</option>
            <option value="50000">&pound;50,000</option>
            <option value="55000">&pound;55,000</option>
            <option value="60000">&pound;60,000</option>
            <option value="65000">&pound;65,000</option>
            <option value="70000">&pound;70,000</option>
            <option value="75000">&pound;75,000</option>
            <option value="80000">&pound;80,000</option>
            <option value="85000">&pound;85,000</option>
            <option value="90000">&pound;90,000</option>
            <option value="95000">&pound;95,000</option>
            <option value="100000">&pound;100,000</option>
            <option value="110000">&pound;110,000</option>
            <option value="120000">&pound;120,000</option>
            <option value="130000">&pound;130,000</option>
            <option value="140000">&pound;140,000</option>
            <option value="150000">&pound;150,000</option>
            <option value="200000">&pound;200,000</option>
            <option value="250000">&pound;250,000</option>
            <option value="300000">&pound;300,000</option>
            <option value="400000">&pound;400,000</option>
            <option value="500000">&pound;500,000</option>
            
          </select>        </td>
      </tr>
      <tr>
        <td height="28"><p>Maximum Price: </p></td>
        <td><select name="mMaxPrice" id="mMaxPrice">
            <option value="99999999">No Max Price</option>
            <option value="100000">&pound;100,000</option>
            <option value="110000">&pound;110,000</option>
            <option value="120000">&pound;120,000</option>
            <option value="130000">&pound;130,000</option>
            <option value="140000">&pound;140,000</option>
            <option value="150000">&pound;150,000</option>
            <option value="200000">&pound;200,000</option>
            <option value="250000">&pound;250,000</option>
            <option value="300000">&pound;300,000</option>
            <option value="400000">&pound;400,000</option>
            <option value="500000">&pound;500,000</option>
            <option value="600000">&pound;600,000</option>
            <option value="700000">&pound;700,000</option>
            <option value="800000">&pound;800,000</option>
            <option value="900000">&pound;900,000</option>
            <option value="1000000">&pound;1,000,000</option>
            
          </select>        </td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td height="28"><p>Minimum Bedrooms:</p></td>
        <td><select name="mMinBeds" id="mMinBeds">
            <option value="0">Any</option>
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>
            <option value="5">5</option>
            <option value="6">6</option>
            <option value="7">7</option>
            <option value="8">8</option>
            <option value="9">9</option>
            <option value="10">10</option>
          </select>        </td>
      </tr>
      <tr>
        <td height="28"><p>Minimum Public Rooms:</p></td>
        <td><select name="mMinPublicRooms" id="mMinPublicRooms">
            <option value="0">Any</option>
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>
            <option value="5">5</option>
            <option value="6">6</option>
            <option value="7">7</option>
            <option value="8">8</option>
            <option value="9">9</option>
            <option value="10">10</option>
          </select>        </td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td height="28"><p>Town:</p></td>
        <td><select name="mTown" id="mTown">
            <option value="%">Any Town</option>
            <%
While (NOT towns.EOF)
%>
            <option value="<%=(towns.Fields.Item("pTown").Value)%>"><%=(towns.Fields.Item("pTown").Value)%></option>
            <%
  towns.MoveNext()
Wend
If (towns.CursorType > 0) Then
  towns.MoveFirst
Else
  towns.Requery
End If
%>
          </select>        </td>
      </tr>
      <tr>
        <td height="28"><p>Property Type: </p></td>
        <td><select name="mBuildingType" id="mBuildingType" tabindex="5">
          <option value="%">Any Type</option>
            <option value="Bungalow">Bungalow</option>
            <option value="Detached">Detached</option>
            <option value="Flat">Flat</option>
            <option value="Semi Detached">Semi Detached</option>
            <option value="Terraced">Terraced</option>
                  </select>        </td>
      </tr>
      
      <tr>
        <td>&nbsp;</td>
        <td height="45" valign="middle"><label>
          <input name="button" type="submit" id="button" value="Submit" />
        </label></td>
        </tr>
    </table></td>
  </tr>
</table>
    
           <input type="hidden" name="MM_insert" value="form1" />
    </form></td>
    </tr>
</table>
     </div>  </td>
    </tr>
  </table>
</div>
<!--#include file="includes/footer.asp" -->
</div>
 
 
</body>
</html>
<%
propertytypes.Close()
Set propertytypes = Nothing
%>
<%
towns.Close()
Set towns = Nothing
%>

Open in new window

0
Comment
Question by:grantballantyne
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 14

Accepted Solution

by:
yessirnosir earned 500 total points
ID: 22750259
line 108:  orphan brace bracket } needs to be removed.  
0
 

Author Closing Comment

by:grantballantyne
ID: 31507454
excellent....thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Making Table Thru ASP Response.write 5 35
How do I add counter to html listbox using jquery 2 40
Put javascript to get dropdown value 3 32
sort Multi-dimensional array 6 40
This article is very specific and is only intended to help if you are installing Dreamweaver 8 in a Windows 7 environment with Office 2007 installed.   I'm not sure why Microsoft tends to release OS' that should not be released but they do.  Windows…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

736 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question