var m =/^([a-zA-Z0-9])([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9])+$/; var con = "http" var con2 = "com" function checkForm(){ if ( document.getElementById('n_name').value == '') { alert('請輸入聯絡人姓名') return false; } if ( document.getElementById('n_tel').value == '') { alert('請輸入電話') return false; } if ( document.getElementById('n_email').value == '') { alert('請輸入email') return false; }else{ if(document.getElementById('n_email').value.match(m)==null){ alert('Email格式錯誤'); document.getElementById('n_email').focus(); return false; } } if ( document.getElementById('n_address').value == '') { alert('請輸入地址'); return false; } if ( document.getElementById('n_message').value == '') { alert('請輸入內容'); return false; } if ( document.getElementById('image').value == '') { alert('請輸入驗證碼'); return false; } if ( document.getElementById('n_message').value.indexOf(con)> -1) { return false; } if ( document.getElementById('n_message').value.indexOf(con2)> -1) { return false; } return true; }