PDA

View Full Version : Code java script không chạy được trên firefox?



benny_quach
28-04-2012, 11:31 PM
Mình làm 1 cái contact form yêu cầu đền đủ tên, comment email nếu ko hợp lệ sẽ bật hộp thoại báo lỗi nhưng không hiểu sao nó chỉ chạy trên IE còn firefox và google chorme thì ko chạy. Mình nghĩ FF đòi hỏi phải là code chuẩn nhưng ko biết code của mình còn phải sửa thế nào.
các bạn xem qua giúp mình nhé, cám ơn!




<head><title>Message</title>
<script type="text/javascript">
function isValidEmail(str) {
return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}
// make sure name text box is filled in

function checkform() {
var cname = document.getElementById('name').value;
var cemail = document.getElementById('email').value;
var ccomment = document.getElementById('comment').value…

// alert(name + " " + email);

if ( cname == "" ) {
alert ("You must enter a full name...");
return false;
}
if ( cemail == "" ) {
alert ("You must enter your email...");
return false;
}
if ( !isValidEmail(cemail) ) {
alert ("You must enter a VALID email address...");
return false;
}
if ( ccomment == "" ) {
alert ("You must enter comment...");
return false;
}
}
</script>