Trim functions of JavaScript

Source: Internet
Author: User

Today, when I was writing JavaScript, I encountered an error. The JS Code is as follows:

 

// Verify the regular expression of the date format. For example
Function isdate (STR )...{
VaR days = new array (, 31 );
VaR A = Str. match (/^ (d... {4}) (-) (d... {1, 2}) (-) (d... {1, 2}) $ /);
If (A = NULL) return false;
Days [1] = (0 = A [1] % 4) & (0! = (A [1] % 100) | (0 = A [1] % 400 )? 29:28;
If (A [1] <= 1900 | A [3] = 0 | A [3]> = 13 | A [5] = 0 | [5]> days [A [3]-1])
Return false;
Return true;
}

Function edittime ()...{
VaR startdate = Document. getelementbyid ("meetstartdate ");
VaR enddate = Document. getelementbyid ("meetenddate ");
If (! Isdate (startdate. value. Trim ()))
...{
Alert ('<Bean: Message key = "label. editmeettime. starttime "/> '+'' +' <Bean: Message key = "MSG. meetboard. startdateiserror "/> ');
Startdate. Focus ();
Return;
}
If (! Isdate (enddate. value. Trim ()))
...{
Alert ('<Bean: Message key = "label. editmeettime. endtime "/> '+'' +' <Bean: Message key = "MSG. meetboard. startdateiserror "/> ');
Enddate. Focus ();
Return;
}

Editmeettimeform. Action = 'savemeettime. Do ';
Editmeettimeform. Submit ();
Window. opener. Location = 'meetboard. do? Meetingid = '+' <Bean: write name = "editmeettimeform" property = "meetdetailid"/> ';
Window. Close ();
}

 

The yellow flag is incorrect. This attribute is not supported. After removing trim (), that's right. I remember using this method before, and no error was reported. After checking the pages that previously supported trim, we found that it would be okay to import Ajax-related JavaScript on the pages, as shown below:

<SCRIPT type = "text/JavaScript" src = "JS/ajaxtags/ajaxtags-1.2-beta2.js"> </SCRIPT>

I searched trim in this JS and found a method like this:

String. Prototype. Trim = function ()...{
Return this. Replace (/(^ s *) | (S * $)/g ,"");
}

So I removed the JS imported above, and added this method only. OK. I still don't know why. I'll try again later.

Recently, I feel like I am using JavaScript ......

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.