How to re-edit letter from the following textbox
$('.zip-code').on('keypress change', function () {
$(this).val(function (index, value) {
return value.replace(/\W/gi, '').replace(/(.{3})/g, '$1 ');
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<label class="label" for="credit-card">zip Code</label>
<input type="text" maxlength="7" class="zip-code" value="" autocomplete="off" />
The above code gives space after 3 letters but unable to re-edit the letter
following are the issues faced :
- should remove entire zip-code to edit a letter in textbox
- If the zip-code entered wrong and if needed to edit it , unable to edit the letter/letters in zip-code field.
- after editing the zip-code the letter moves to the end.