
function isNumeric(s)
{
     var isNum = /\d/;
     if( !isNum.test(s) ) return 0; 
     return 1;
}

function isNumer(s)
{
     var isNum = /^[\d]+$/;
     if( s.search(isNum) ) return 0; 
     return 1;
}

function checkSpace( str )
{
     if(str.search(/\s/) != -1){
     	return 1;
     }

     else {
         return "";
     }
}

function validID( str )
{
     /* check whether input value is included space or not  */
     if( str == ""){
     	alert("Please enter your ID");
     	return 0;
     }
     
     var retVal = checkSpace( str ); 
             
     if( retVal != "" ) {
         alert("User Id may not have any space between characters.");
         return 0; 
     } 
     if( str.charAt(0) == '_') {
	 alert("User ID cannot begin with '_'");
	 return 0;
     }

     /* checkFormat  */
     var isID = /^[a-z0-9_]{3,12}$/;
     if( !isID.test(str) ) {
         alert("User ID length should be between 3 to 12 characters."); 
         return 0; 
     }
     return 1;
}

function validPWD( str )
{
     var cnt=0;
     if( str == ""){
     	alert("Please enter password");
     	return 0;
     }     

    /* check whether input value is included space or not  */
     var retVal = checkSpace( str );
     if( retVal != "") {
         alert("User ID may not have any space between characters.");
         return 0;
     }
     for( var i=0; i < str.length; ++i)
     {
         if( str.charAt(0) == str.substring( i, i+1 ) ) ++cnt;
     }  

     return 1;
}

function validEMAIL( str )
{
     /* check whether input value is included space or not  */
     if(str == ""){
     	alert("Please enter your email address.");
     	return 0;
     }
     var retVal = checkSpace( str );
     if( retVal != "") {
         alert("Email address may not have any space.");
         return 0;
     }
          
     /* checkFormat */
     var isEmail = /[-!#$%&'*+\/^_~{}|0-9a-zA-Z]+(\.[-!#$%&'*+\/^_~{}|0-9a-zA-Z]+)*@[-!#$%&'*+\/^_~{}|0-9a-zA-Z]+(\.[-!#$%&'*+\/^_~{}|0-9a-zA-Z]+)*/;
     if( !isEmail.test(str) ) {
         alert("Invalid email format.");
         return 0;
     }
     if( str.length > 60 ) {
         alert("E-mail may not exceed 60 characters.");
         return 0;
     }

     return 1;
}