function checkForm(){

    if(document.getElementById('addr1').checked==false && document.getElementById('addr2').checked==false){
        alert('用途を選択してください');
        document.getElementById('addr1').focus();
        return false;
    }
    if(document.getElementById('fname').value==''){
        alert('お名前を入力して下さい');
        document.getElementById('fname').focus();
        return false;
    }
    /*if(document.getElementById('email').value==''){
        alert('メールアドレスを入力して下さい');
        document.getElementById('email').focus();
        return false;
    }*/
    if(!ValidateMail())
        return false;
    
    if(document.getElementById('city').value==''){
        alert('設置のご住所を入力して下さい');
        document.getElementById('city').focus();
        return false;
    }
    if(document.getElementById('fname2').value==''){
        alert('設置のご住所を入力して下さい');
        document.getElementById('fname2').focus();
        return false;
    }
    if(document.getElementById('hospital1').checked==false && document.getElementById('hospital2').checked==false && document.getElementById('hospital3').checked==false){
        alert('ご希望を選択してください');
        document.getElementById('hospital1').focus();
        return false;
    }
    if(document.getElementById('hospital2').checked==true && document.getElementById('affiliate').value==''){
        alert('質問希望を入力してください');
        document.getElementById('affiliate').focus();
        return false;
    }
    if(document.getElementById('hospital3').checked==true && document.getElementById('position').value==''){
        alert('送付先をご記入ください');
        document.getElementById('position').focus();
        return false;
    }
	if(document.getElementById('6_letters_code').value==''){
		alert('文字列が一致しません');
        document.getElementById('6_letters_code').focus();
        return false;
	}

}



function echeck(str) {

        var at="@";
        var dot=".";
        var lat=str.indexOf(at);
        var lstr=str.length;
        var ldot=str.indexOf(dot);
        if (str.indexOf(at)==-1){
           alert("メールアドレスを入力して下さい");
           return false;
        }

        if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
           alert("メールアドレスを入力して下さい");
           return false;
        }

        if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
            alert("メールアドレスを入力して下さい");
            return false;
        }

         if (str.indexOf(at,(lat+1))!=-1){
            alert("メールアドレスを入力して下さい");
            return false;
         }

         if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
            alert("メールアドレスを入力して下さい");
            return false;
         }

         if (str.indexOf(dot,(lat+2))==-1){
            alert("メールアドレスを入力して下さい");
            return false;
         }
        
         if (str.indexOf(" ")!=-1){
            alert("メールアドレスを入力して下さい");
            return false;
         }

          return true;            
    }

function ValidateMail(){
    var emailID=document.getElementById('email');
    
    if ((emailID.value==null)||(emailID.value=="")){
        alert("メールアドレスを入力して下さい");
        emailID.focus();
        return false;
    }
    if (echeck(emailID.value)==false){
        emailID.focus();
        return false;
    }
    return true;
 }

