For example, if a user enter alphabet in a 'Phone' input field and I want to display a line of message 'Only numeric number is allow' under the input field. How can I do this?
I tried:
<div> <label>Cell Phone No</label> <input type="text" name="cellphnumber" value="" class="form-control"> </div>
<?php if (!preg_match ("/^[0-9]*$/", $cellphnumber) ) {
echo <p>"Only numberic value is allowed."</p>
}?>
AND
<div> <label>Cell Phone No</label> <input type="text" name="cellphnumber" value="" class="form-control"> </div>
<script>
if (!preg_match ("/^[0-9]*$/", $cellphnumber) ) {
<a>Only numeric value is allowed.</a>;
}
</script>