Reputation: 2000
All values for a text box begin with T-
how do I have a textbox prepopulated with T-
where the user cannot remove the T-
Thanks for your help
Upvotes: 0
Views: 1909
Reputation: 543
Attach the label before the textbox and give textbox left-border to 0px and label right-border to 0px. While getting the value add both the values. hope it helps you.
Upvotes: 0
Reputation: 15387
Try this
<input id="field" type="text" value="T-" size="50" />
JS
var readOnlyLength = $('#field').val().length;
$('#output').text(readOnlyLength);
$('#field').on('keypress, keydown', function(event) {
var $field = $(this);
$('#output').text(event.which + '-' + this.selectionStart);
if ((event.which != 37 && (event.which != 39))
&& ((this.selectionStart < readOnlyLength)
|| ((this.selectionStart == readOnlyLength) && (event.which == 8)))) {
return false;
}
});
Upvotes: 3