Hi, I would like to ask does anyone knows how to validate yii timepicker?
For example, I input [color="#FF0000"]class start:10am[/color] and [color="#FF0000"]class end:8am[/color] (attachment), it is still can be saved successfully although the time input is wrong. Is there anyone knows how to validate the time input, so that the user knows there is an error of time input?
Yes, you can add your own validation functions. In this function you do some checks if the time is correct and if not, you set an error.
In your model rules:
public function rules()
array('start, end', 'validateTimeField'),
In your model
// Custom validation for time field.
public function validateTimeField($attribute,$params)
if($this->start == '' || $this->end == '')
$this->addError($attribute, $this->getAttributeLabel('Hey fool, fill in the start AND end time please!');
//This is just an example, you will have to do some proper check if times are correct
if($this->start < $this->end == '')