// Remove spaces at both ends of the string. The usage is string. Trim ()
String. Prototype. Trim = function ()
{
Return this. Replace (/(^/S *) | (/S * $)/g ,"");
}
Function checkinput ()
{
// Verification name
Document. form1.addmessage1 _ messagetitle. value = Document. form1.addmessage1 _ messagetitle. value. Trim ();
If (document. form1.addmessage1 _ messagetitle. value = "")
{
Alert ("Enter the Message Title ");
Event. cancelbubble = true;
Event. returnvalue = false;
Document. form1.addmessage1 _ messagetitle. Focus ();
Return false;
}
// Verify the message content
Document. form1.addmessage1 _ content. value = Document. form1.addmessage1 _ content. value. Trim ();
If (document. form1.addmessage1 _ content. value = "")
{
Alert ("Enter the message content ");
Event. cancelbubble = true;
Event. returnvalue = false;
Document. form1.addmessage1 _ content. Focus ();
Return false;
}
// Verify the input length
If (document. form1.addmessage1 _ content. value. length> 1000)
{
Alert ("the detailed description of the project you entered is too long. You can enter up to 1000 words ");
Event. cancelbubble = true;
Event. returnvalue = false;
Document. form1.addmessage1 _ content. Focus ();
Return false;
}
// Verify the contact name
Document. form1.addmessage1 _ leaveman. value = Document. form1.addmessage1 _ leaveman. value. Trim ();
If (document. form1.addmessage1 _ leaveman. value = "")
{
Alert ("enter your name ");
Event. cancelbubble = true;
Event. returnvalue = false;
Document. form1.addmessage1 _ leaveman. Focus ();
Return false;
}
// Verify the mobile phone number
Document. form1.addmessage1 _ mobile. value = Document. form1.addmessage1 _ mobile. value. Trim ();
/* If (document. form1.addmessage1 _ msgmobile. value = "")
{
Alert ("Enter your mobile phone number ");
Event. cancelbubble = true;
Event. returnvalue = false;
Document. form1.addmessage1 _ msgmobile. Focus ();
Return false;
}*/
// Verify the validity of the mobile phone number
/* Rege =/^ 13/d {9} $ /;
If (! Rege. Test (document. form1.addmessage1 _ msgmobile. Value ))
{
Alert ("invalid mobile phone number ");
Event. cancelbubble = true;
Event. returnvalue = false;
Document. form1.addmessage1 _ msgmobile. Focus ();
Return false;
}
*/
// Phone number
Document. form1.addmessage1 _ phone. value = Document. form1.addmessage1 _ phone. value. Trim ();
If (document. form1.addmessage1 _ phone. value = "")
{
Alert ("Enter your phone number ");
Event. cancelbubble = true;
Event. returnvalue = false;
Document. form1.addmessage1 _ phone. Focus ();
Return false;
} Else
{
If (! Document. form1.addmessage1 _ phone. value. length> 7)
{
Alert ("the number of phone numbers you entered is incorrect! ");
Event. cancelbubble = true;
Event. returnvalue = false;
Document. form1.addmessage1 _ phone. Focus ();
Return false;
}
}
// Contact address
Document. form1.addmessage1 _ contactaddress. value = Document. form1.addmessage1 _ contactaddress. value. Trim ();
If (document. form1.addmessage1 _ contactaddress. value = "")
{
Alert ("Enter the contact address ");
Event. cancelbubble = true;
Event. returnvalue = false;
Document. form1.addmessage1 _ contactaddress. Focus ();
Return false;
}
// Zip code
Document. form1.addmessage1 _ postcode. value = Document. form1.addmessage1 _ postcode. value. Trim ();
If (document. form1.addmessage1 _ postcode. value = "")
{
Alert ("Enter the zip code ");
Event. cancelbubble = true;
Event. returnvalue = false;
Document. form1.addmessage1 _ postcode. Focus ();
Return false;
}
// QQ
Document. form1.addmessage1 _ QQ. value = Document. form1.addmessage1 _ QQ. value. Trim ();
// Msn
Document. form1.addmessage1 _ MSN. value = Document. form1.addmessage1 _ MSN. value. Trim ();
If (document. form1.addmessage1 _ MSN. value = "")
{
/* Alert ("Enter the MSN address ");
Event. cancelbubble = true;
Event. returnvalue = false;
Document. form1.addmessage1 _ msgmsn. Focus ();
Return false ;*/
}
Else
{
Rege =/^ ([a-zA-Z0-9] + [_ |/-|/.]?) * [A-zA-Z0-9] + @ ([a-zA-Z0-9] + [_ |/-|/.]?) * [A-zA-Z0-9] +/. [A-Za-Z] {2, 3} $ /;
/* If (! Rege. Test (document. form1.msn. Value ))
{
Alert ("invalid MSN address ");
Event. cancelbubble = true;
Event. returnvalue = false;
Document. form1.msn. Focus ();
Return false;
}*/
}
// Email
Document. form1.addmessage1 _ email. value = Document. form1.addmessage1 _ email. value. Trim ();
If (document. form1.addmessage1 _ email. value = "")
{
/* Alert ("Enter the e_mail address ");
Event. cancelbubble = true;
Event. returnvalue = false;
Document. form1.addmessage1 _ email. Focus ();
Return false ;*/
}
Else
{
Rege =/^ ([a-zA-Z0-9] + [_ |/-|/.]?) * [A-zA-Z0-9] + @ ([a-zA-Z0-9] + [_ |/-|/.]?) * [A-zA-Z0-9] +/. [A-Za-Z] {2, 3} $ /;
If (! Rege. Test (document. form1.addmessage1 _ email. Value ))
{
Alert ("invalid email address ");
Event. cancelbubble = true;
Event. returnvalue = false;
Document. form1.addmessage1 _ email. Focus ();
Return false;
}
}
}