Category: Javascript

Q: jQuery validation and CakePHP not working together

I want to use jquery validation and CakePHP together.

<?= $this->Form->create($email, ['url' => ['action' => 'newEmail']]); ?>
<?= $this->Form->input('email', ['required' => 'required']); ?>
<?= $this->Form->end(); ?>
<script>
$("#emailform").validate();
</script>

But it doesn't work in my app, what should I do to fix the problem? 

jquery
1 Answers

Version: 3

In my experience, you have to add an id attribute in HTML form tag:

<?= $this->Form->create($email, ['url' => ['action' => 'newEmail'], 'id' => 'emailForm']); ?>
Luke
Luke

3