JSFiddle - React, Tailwind, and code Playground
HTML
<input type='text' id='textboxId' value='2014/09/01'>
JavaScript
(function ($, undefined) {
$.fn.getCursorPosition = function() {
var el = $(this).get(0);
var pos = 0;
if('selectionStart' in el) {
pos = el.selectionStart;
} else if('selection' in document) {
el.focus();
var Sel = document.selection.createRange();
var SelLength = document.selection.createRange().text.length;
Sel.moveStart('character', -el.value.length);
pos = Sel.text.length - SelLength;
}
return pos;
}
})(jQuery);
$("#textboxId").keydown(function(e){
var currentPos=$(this).getCursorPosition();
var lastChar=$(this).val().substr((currentPos- $(this).val().length)- 1);
if(e.which==8 && lastChar.match(/^\//g) ){
e.preventDefault();
return false;
}
});