I'm currently using:
<script src="//code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<script src="../js/bootStrap/js/bootstrap.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/additional-methods.min.js"></script>
with validation such as:
j$('.delValidate').each(function(){
j$(this).validate({
rules:{
delivery_Method:{
required: true
}
},
message:{
delivery_Method:{
required: true
}
}
});
});
j$('.validateUser').each(function(){
j$(this).validate({
rules:{
f_Name:{
required: true
},
l_Name:{
required: true
},
username:{
required: true,
minlength: 6
},
password: {
validChars: true,
noSpace: true,
minlength: 6,
skip_or_fill_minimum: [3,".pw"]
},
confPass: {
equalTo: "#password",
skip_or_fill_minimum: [3,".pw"]
}
}
});
});
HTML snippet:
<form class="form-horizontal delValidate" action="#" method="post">
<input type="hidden" name="formIdentifier" value="addDel" />
<div class="form-group">
<div class="col-sm-3">
<input type="text" name="delivery_Method" class="form-control" placeholder="Enter new method" />
</div>
<div class="col-sm-2 col-sm-offset-2">
<button type="submit" class="btn btn-default btn-block">Add</button>
</div>
</div>
</form>
But when I go to my page, My form is rendered with the attribute noValidate and therefore I can insert null/empty values into the database. What is the reasoning for this? Does the form have to be set up in a particular way? Does jQuery validation pick up something is wrong and therefore doesn't work? My dirty work around is using:
j$(this).removeAttr('novalidate');