jQuery를 사용하여 양식 유효성 검증 스크립트를 작성하려고합니다.jQuery - 양식 유효성 검사
그러나 작동하지 않는 것 같습니다. 아마도 사소한 것이지만 문제의 원인을 찾을 수 없습니다.
또한 jQuery를 사용하기 시작했는데 좋은 구문 검사기를 찾고 있습니다. 누구든지 추천 할 수 있습니까?
$(document).ready(function() {
$('.error').toggle();
});
//when the button is clicked
$(".button").click(function() {
// validate and process form
// first hide any error messages
$('.error').hide();
var name = $("input#name").val();
if (name == "") {
$("label#name_error").show();
return false;
}
var name = $("input#email").val();
if (name == "") {
$("label#name_error").show();
return false;
}
var name = $("input#subject").val();
if (name == "") {
$("label#name_error").show();
return false;
}
var name = $("textarea#message").val();
if (name == "") {
$("label#name_error").show();
return false;
}
var dataString = 'name='+ name + '&email=' + email + '&phone=' + phone;
$.ajax({
type: "POST",
url: "bin/process.php",
data: dataString,
success: function() {
$('#contact_form').html("<div id='message'></div>");
$('#message').html("<h2>Contact Form Submitted!</h2>")
.append("<p>We will be in touch soon.</p>")
.hide()
.fadeIn(1500, function() {
$('#message').append("<img id='checkmark' src='images/check.png' />");
});
}
});
return false;
});
});