number validation by codeiginter form
<div class="col-sm-3">
<div>
<label for="phone_no" class="control-label">Contact No. <span class="text-danger">*</span></label>
<input type="number" minlength="11" maxlength="11" required id="phone_no"
value="<?php echo set_value('phone_no'); ?>" class="form-control" name="phone_no"
placeholder="Enter Contact No." oninput="validity.valid||(value='');" />
<?php echo form_error('phone_no');?>
</div>
</div>
<?php
$this->form_validation->set_error_delimiters('<div class="errorValid">', '</div>');
$this->form_validation->set_rules('phone_no', 'Contact No ', 'required|regex_match[/^[0-9]{11}$/]'); //{11} for 11 digits number
if ($this->form_validation->run() == false)
?>
Comments
Post a Comment