$input = '12345abc'; if(strlen($input) != 10){ echo 'Input harus 10 digits'; }
<script type="text/javascript"> var input = '12345abc'; if(input.length != 10){ alert('Input harus 10 digits'); return; } </script>
<script type="text/javascript"> var input = '12345abc'; var regex = /\d{10}/; if(!regex.test(input)){ alert('Input harus 10 digits angkat'); return; } </script>
<script type="text/javascript> var input = '1234567890d'; var regex = /^\d{10}$/; if(!regex.test(input)){ alert('Input harus 10 digits angkat'); } </script>