I have tried this below validations for my fields.
My fields are Title, Content.
var $validate = array('title' =>array('alphaNumeric'=>array('rule'=>'alphaNumeric','required'=>'true','message'=>'Enter a title for this post',)),
'content'=>array('alphaNumeric'=>array('rule'=>'alphaNumeric','required'=>'true','message'=>'Enter some content for this post',)));
But whenever i enter some text in my form and try to submit, it shows error message…
Is there any problem with the validations ?
Here’s my form
<h2> Add a Post Here </h2>
Please fill in all the fields.
<?php
echo $this->form->create('Post');
echo $this->form->error('Post.title');
echo $this->form- >input('Post.title',array('id'=>'posttitle','label'=>'title','size'=>'50','maxlength'=>'255','error'=>false));
echo $this->form->error('Post.content');
echo $this->form->input('Post.content',array('id'=>'postcontent','type'=>'textarea','label'=>'Content:','rows'=>'10','error'=>false));
echo $this->form->end(array('label'=>'Submit Post'));
?>
you can use custom regular expression.