Form validitáció jQuery-vel
Sziasztok!
Az lenne a problémám hogy megírtam egy form validitációt jQueryvel ami le is ellenőrzi rendesen csak miután megtette és megfelel minden feltételnek azután nem küldi tovább a formot. Hogyan lehet ezt megvalósítani?
index.htmlform.jsElőre is köszi a segítséget.
■ Az lenne a problémám hogy megírtam egy form validitációt jQueryvel ami le is ellenőrzi rendesen csak miután megtette és megfelel minden feltételnek azután nem küldi tovább a formot. Hogyan lehet ezt megvalósítani?
index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="css/form.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.validate.js"></script>
<script type="text/javascript" src="js/form.js"></script>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Putting together...</title>
</head>
<body>
<div align="center"><h1><i>Putting together...</i></h1></div>
<div class="stuff">
<form action="<?=$_SERVER['PHP_SELF'];?>" method="post" enctype="multipart/form-data" name="upload" id="form">
<b>Your E-mail address: *</b><br />
<input type="text" name="eemail" size="36" id="eemail" value="" /><br />
<b>Confirm your E-mail: *</b><br />
<input type="text" name="cemail" size="36" id="cemail" value="" /><br />
<b>Recipient's E-mail: *</b><br />
<input type="text" name="remail" size="36" id="remail" value="" /><br />
<b>Subject: *</b><br />
<input class="textbox" type="text" name="subject" id="subject" size="36" value="" /><br />
<b>Message: *</b><br />
<textarea class="textbox" name="message" rows="10" cols="60"></textarea>
<br /><br />
Max file size:400kb! Allowed picture formats: jpg, gif, png.<br /><br />
<input type="file" name="image" size="60" /><br />
I agree with the <i><a href="terms.php">terms</a></i> of use.
<input type="checkbox" name="terms" id="terms" value="1" /><br />
<input type="submit" name="submit" id="submit" value=" Send! " /><br /><br />
</form>
</div>
<?php
require_once 'php/upload.php';
if(isset($_POST['submit'])){
print '<div class="upload">';
upload();
print '</div>';
}
?>
</body>
</html>
jQuery.validator.setDefaults({
debug: true,
success: "valid"
});
$(document).ready(function () {
$("form").validate({
rules: {
eemail: {
required: true,
email: true,
maxlength: 50
},
cemail: {
required: true,
email: true,
maxlength: 50,
equalTo: "#eemail"
},
remail: {
required: true,
email: true,
maxlength: 50
},
subject: {
required: true,
maxlength: 50
},
terms: "required"
},
messages: {
eemail: {
required: "Please specify your email adress!",
email: "Please give a valid email adress!",
maxlength: "Please make sure that your email adress is not longer than 50 characters."
},
cemail: {
required: "Please specify your email adress!",
email: "Please give a valid email adress!",
maxlength: "Please make sure that your email adress is not longer than 50 characters."
},
remail: {
required: "Please specify your email adress!",
email: "Please give a valid email adress!",
maxlength: "Please make sure that your email adress is not longer than 50 characters."
},
subject: {
required: "Please specify the subject!",
maxlength: "Please make sure that the subject is not longer than 50 characters."
},
terms: " "
}
});
});
a steDefault-bol szedd ki a