I need to create a validation for my input to limit it 10 char, I dunno why my code doesnt work
{{ Form::label('send-txt', 'Category Code', array('class' => 'control-label')) }}
{{ Form::text('code', null, array('class' => 'form-control', 'placeholder' => 'Category Code')) }}
$(document).ready( function() {
var maxLen = 10;
$('#send-txt').keypress(function(event){
var Length = $("#send-txt").val().length;
var AmountLeft = maxLen - Length;
$('#txt-length-left').html(AmountLeft);
if(Length >= maxLen){
if (event.which != 8) {
return false;
}
}
});
});
I used laravel 4.2