codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Problem - Object doesn`t support this property or method  robersen at 07:32 on Wednesday, August 29, 2007
 

Hi,

I have a form validating 3 radio buttons, and individually the fields are validated. The Date field is validated onChange event for the date format.
The 1st Date field is properly validated, when the 2nd Date field onChange event is called, iam getting an error "Object does not support this property or Method.

Please help me in solving this problem. The code is given below.

---------------------------------------------------------
<html>

<head>
<title></title>
<script language=javascript type=text/javascript>
<!--
function disableField() {
document.myform.checknumber.value='None';
document.myform.checknumber.disabled=true;
document.myform.checkdate.value='None';
document.myform.checkdate.disabled=true;
document.myform.swiftnumber.value='None';
document.myform.swiftnumber.disabled=true;
document.myform.swiftdate.value='None';
document.myform.swiftdate.disabled=true;
}
function enablecheque() {
document.myform.checknumber.disabled=false;
document.myform.checkdate.disabled=false;
document.myform.checknumber.value='';
document.myform.checkdate.value='';
document.myform.swiftnumber.value='None';
document.myform.swiftnumber.disabled=true;
document.myform.swiftdate.value='None';
document.myform.swiftdate.disabled=true;
}
function enableswift() {
document.myform.swiftnumber.disabled=false;
document.myform.swiftnumber.value='';
document.myform.swiftdate.disabled=false;
document.myform.swiftdate.value='';
document.myform.checknumber.value='None';
document.myform.checknumber.disabled=true;
document.myform.checkdate.value='None';
document.myform.checkdate.disabled=true;
}



function TextField_Validator()
{
if (myform.checknumber.value == "" || myform.checkdate.value == "" || myform.swiftnumber.value == "" || myform.swiftdate.value == "")
{
alert("Please fill in the text field.");

return (false);
}
return (true);
}


var dtCh= "/index.html";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
var i;
for (i = 0; i < s.length; i++){
// Check that current character is number.
var c = s.charAt(i);
if (((c < "0") || (c > "9"))) return false;
}
// All characters are numbers.
return true;
}

function stripCharsInBag(s, bag){
var i;
var returnString = "";
// Search through string's characters one by one.
// If character is not in bag, append to returnString.
for (i = 0; i < s.length; i++){
var c = s.charAt(i);
if (bag.indexOf(c) == -1) returnString += c;
}
return returnString;
}

function daysInFebruary (year){
// February has 29 days in any year evenly divisible by four,
// EXCEPT for centurial years which are not also divisible by 400.
return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
for (var i = 1; i <= n; i++) {
this = 31
if (i==4 || i==6 || i==9 || i==11) {this = 30}
if (i==2) {this = 29}
}
return this
}

function isDate(dtStr){
var daysInMonth = DaysArray(12)
var pos1=dtStr.indexOf(dtCh)
var pos2=dtStr.indexOf(dtCh,pos1+1)
var strDay=dtStr.substring(0,pos1)
var strMonth=dtStr.substring(pos1+1,pos2)
var strYear=dtStr.substring(pos2+1)
strYr=strYear
if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
for (var i = 1; i <= 3; i++) {
if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
}
month=parseInt(strMonth)
day=parseInt(strDay)
year=parseInt(strYr)




if (pos1==-1 || pos2==-1){
alert("The date format should be : dd/mm/yyyy")
return false
}
if (strMonth.length<1 || month<1 || month>12){
alert("Please enter a valid month")
return false
}
if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
alert("Please enter a valid day")
return false
}
if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
return false
}
if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
alert("Please enter a valid date")
return false
}
return true
}


function chequedate(){

var dt= document.myform.checkdate

if (dt.value == "") {
return true
}
else if (isDate(dt.value)==false) {

dt.focus()
return false
}
return true
}

function swiftdate(){
var dt=document.myform.swiftdate

if (dt.value == "") {
return true
}
else if (isDate(dt.value)==false){

dt.focus()
return false
}
return true
}


</script>

<FORM
ACTION="http://www.ebay.com"
NAME="myform"
METHOD="post"
onsubmit="return TextField_Validator()"
>

<p>
<input type="radio" name="button" value="cheque" onclick="enablecheque()" />
Cheque
 </p>

<p>Cheque  
<input name="checknumber" type="text" disabled="disabled" id="checknumber" value="" size="30" />
<p>Enter a Date: <font color="#CC0000"><b>(dd/mm/yyyy)</b></font>

<input type="text" disabled="disabled" name="checkdate" maxlength="10" size="15" onchange = "return chequedate()">
</p>
<p>
<input type="radio" name="button" value="swift" onclick="enableswift()" />
 Swift  </p>

<p>Swift
<input name="swiftnumber" type="text" disabled="disabled" id="swiftnumber" value="" size="30" />
<p>Enter a Date: <font color="#CC0000"><b>(dd/mm/yyyy)</b></font>

<input type="text" disabled="disabled" name="swiftdate" maxlength="10" size="15" onchange = "return swiftdate()">
</p>

<p>
<input type="radio" name="button" value="online" onclick="disableField()" />
Online </p>


<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>

</body>
</html>

-----------------------------------------------------

  Re: Problem - Object doesn`t support this property or method  arash farhad at 12:05 on Friday, March 12, 2010
 

Beautiful blog with great informational content. Mostly certifications related and method related topics are really very good. mcp certification dumps, 1z0-146 dumps and mcp dumps are also good topics. Thanks for this great sharing.

  Re: Problem - Object doesn`t support this property or method  arash farhad at 12:07 on Friday, March 12, 2010
 

Ground shaking content i get form your blog. Very nice post about property or method. Thanks for your beneficial information about 70-270 braindumps, 70-236 braindumps and mcitp braindumps certifications. These are the best certifications in the world.








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  How work this reusable form validation script ?
•  Re: Copy files from one directory to another in a local network
•  DLL
•  calendar or event management
•  Re: how to convert wav file to text file
•  Re: huffman encoding and decoding in C++...
•  Re: How to Change user to root using ssh::expect
•  Re: Need hosted_button_id value from PayPal generated code
•  Re: need help creating mysql database for my java code


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2010