Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New Coder
    Join Date
    Nov 2006
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Where I do mistake please help me

    I find this code my comment component file.
    the date seems 2003 year whit this code so the comments is write 2003 year.the server time is true.

    How can I solve this problem

    Code:
    /*< date datetime *******************************************************************/
    fValidate.prototype.date = function( formatStr, delim, code, specDate )
    {
    	if ( this.typeMismatch( 'text' ) ) return;
    	if ( typeof formatStr == 'undefined' )
    	{
    		this.paramError( 'formatStr' );
    		return;
    	}
    
    	delim = this.setArg( delim, "/" );
    
    	var error	= [this.elem.fName, formatStr.replace( /\//g, delim )];
    	var format  = formatStr.split( "/" );
    	var compare = this.elem.value.split( delim );
    	var order   = new Object();
    	
    	for ( var i = 0; i < format.length; i++ )
    	{
    		switch( format[i].charAt( 0 ).toLowerCase() )
    		{
    			case 'm' :
    				order.months = i;
    				break;
    			case 'd' :
    				order.days = i;
    				break;
    			case 'y' :
    				order.years = i;
    				break;
    		}
    	}
    	var thisDate = new Date( compare[order.years], compare[order.months]-1, compare[order.days] );
    	
    	if ( isNaN( thisDate ) || thisDate.getDate() != compare[order.days] || thisDate.getMonth() != compare[order.months]-1 || thisDate.getFullYear().toString().length != formatStr.match( /y/g ).length )
    	{
    		this.throwError( error );
    		return;
    	}
    	
    	var compareElem = this.form.elements[specDate];
    	if ( typeof compareElem != 'undefined' )
    	{
    		specDate = compareElem.validDate || compareElem.value;
    	}
    	var compareDate = ( specDate == 'today' )?
    		new Date():
    		new Date( specDate );
    	compareDate.setHours(0);
    	compareDate.setMinutes(0);
    	compareDate.setSeconds(0);
    	compareDate.setMilliseconds(0);
    	
    	var timeDiff = compareDate.getTime() - thisDate.getTime();
    	var dateOk   = false;
    	
    	switch ( parseInt( code ) ) {
    		case 1 :	// Before specDate
    			dateOk	= Boolean( timeDiff > 0 );
    			error	= 1;
    			break;
    		case 2 :	// Before or on specDate
    			dateOk	= Boolean( ( timeDiff + 86400000 ) > 0 );
    			error	= 2;
    			break;
    		case 3 :	// After specDate
    			dateOk	= Boolean( timeDiff < 0 );
    			error	= 3;
    			break;
    		case 4 :	// After or on specDate
    			dateOk	= Boolean( ( timeDiff - 86400000 ) < 0 );
    			error	= 4;
    			break;
    		default : dateOk = true;
    		}
    	if ( !dateOk )
    	{
    		this.throwError( [specDate], error );
    	}
    	this.elem.validDate = thisDate.toString();
    }	
    /*/>*/
    Attached Files Attached Files


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •