Shaani
(Aziz Zee)
1
<div class="enquiry-input-area"><?php $defaultText='Type your comments in here...';
if(empty($model->comments))
$model->comments=$defaultText;
echo $form->textArea($model, 'comments', array("class"=>"contact-textarea", "id"=>"txtEnquiry", "onblur"=>"javascript:autoHide(this,'".$defaultText."')","onfocus"=>"javascript:autoHide(this,'".$defaultText."')")); ?></div>
array('urlerror, country, email, comments, whatreport', 'required', 'on'=>'feedback', 'message'=>'Insert {attribute}'),
How can I make a check that would show error message if the field value is default text ‘Type your comments in here…’ ?
As for me, I prefer to use ‘placeholder’ attribute (and jquery plugin for old browsers support, for example: https://github.com/mathiasbynens/jquery-placeholder)
But if you really need to leave this text inside textarea, I think you should use built-in Compare validator.
http://www.yiiframework.com/wiki/56/#hh7
Shaani
(Aziz Zee)
3
I tried this but it doesn’t show error message if the textarea is not filled
array('comments', 'compare', 'compareValue' => "Type your comments in here..."),
You forgot comparison operator.
array('comments', 'compare', 'compareValue' => 'Type your comments in here...', 'operator' => '!=')