My jQuery code is:
$(document).ready(function(){
$('#StudentRegisterForm').validate({
rules: {
email: {
required:true,
email:true
}
}
});
});
and in my form email:
<td><?php echo $form->input('email',array('class required email')); ?></td>
The problem is jquery validate plugin works on the input fields attribute 'name' but cakephp names it as data[Student][email]
. If I use this name in jquery its throwing an error. If I rename the field in cakephp the email value is not passed to the database. Is there any other round about way?
You need just need a minor tweak, set the rule using a string, like this:
$(function(){ //short for $(document).ready(function(){
$('#RegisterForm').validate({
rules: {
"data[Student][email]": {
required:true,
email:true
}
}
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With