-2

I have a text box i need to append "-" in date format

Like I type DD-MM-YYYY in text box

when users enter Date-(This should automatically come) than month (- this should automatically come ) and than later year

so when i enter something in text box like this

29-06-1992

How to do it in JavaScript or Jquery

Basant12
  • 31
  • 6

1 Answers1

0

Try this one:

$(document).on('keyup','#your_textbox_id',function(){
if($('#your_textbox_id').val().length == 2){
$('#your_textbox_id').val( $('#your_textbox_id').val().substring(0,2) +'-')
}
else if($('#your_textbox_id').val().length == 5){
$('#your_textbox_id').val( $('#your_textbox_id').val().substring(0,5) +'-')
}
})
Mohammed Shiyas
  • 63
  • 1
  • 11