im using the jQuery Validate plugin but its not firing for me, I have an action on my php form which lets me handle images and also send the rest of the info to a db. here is my code any help would be appreciated. I got it to stop submission so its not redirecting at all. I need it to check values and if its all good then fire the action.
<form name="form2" enctype="multipart/form-data" method="post" action="upload.php" id="newProject"/>
<div class="inputs">
<p>
<span class="required"></span>
<input type="text" name="title" placeholder="Title:" value="Title of Image" />
<small>This is the <strong>Title</strong> of the image.</small>
</p>
<p>
<span class="required"></span>
<input type="text" name="description" placeholder="Description:" value="Description" />
<small><strong>Description</strong> is shortened on main pages but will be fully displayed on the <strong>Single page</strong></small>
</p>
<p><span class="required"></span>
<input class="checkBox" type="checkbox" name="category" value="1">Landscape<br />
<span class="required"></span>
<input class="checkBox" type="checkbox" name="category" value="2">Portrait<br />
<span class="required"></span>
<input class="checkBox" type="checkbox" name="category" value="3">Monochrome<br />
<small></small>
</p>
<p><span class="required"></span>
<input class="uploadFile" type="file" size="32" name="my_field" value="" />
<input type="hidden" name="action" value="image" /></p>
<div class="actions">
<p><button class="button" id="update_profile" value="upload">Upload</button></p>
</div>
</div>
</form>
<script language="javascript" type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script language="javascript" type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.10.0/jquery.validate.min.js"></script>
<script>
$(function() {
$( "#newProject" ).validate({
rules: {
title: {
required: true,
minlength: 4,
maxlength: 20
}
description: {
required: true,
minlength: 20,
maxlength: 500
}
},
messages: {
title: {
required: "Enter a title",
minlength: $.format("Keep typing, at least {0} characters required!"),
maxlength: $.format("Whoa! Maximum {0} characters allowed!")
}
description: {
required: "Enter a description",
minlength: $.format("Keep typing, at least {0} characters required!"),
maxlength: $.format("Whoa! Maximum {0} characters allowed!")
}
}
});
});
</script>
<script>
$(function(){
$("#newProject").on('submit', function(e){
var isvalidate=$("#newProject").valid();
if(isvalidate)
{
e.preventDefault();
alert(getvalues("newProject"));
}
});
});
function getvalues(f)
{
var form=$("#"+f);
var str='';
$("input:not('input:submit')", form).each(function(i){
str+='\n'+$(this).prop('title')+': '+$(this).val();
});
return str;
}
</script>