/** * Set a minimum and maximum value to a field * * @param $min * @param $max */ public function setBetween($min, $max) { if ($this->field->isOfType('number') == 'min') { // min, max values for generation of the pattern $this->field->min($min); $this->field->max($max); } else { $this->field->pattern('.{' . $min . ',' . $max . '}'); // still let the browser limit text input after reaching the max $this->field->maxlength($max); } }