How to auto format textbox inputs

后端 未结 4 1406
野性不改
野性不改 2020-12-21 23:36

   
      
   <         


        
4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-21 23:44

    use datepicker api from jquery here is the link Datepicker

    and here is the working code

    
       
          
       
    
    
    
    

    EDIT

    $("input[name='birthdate']:first").keyup(function(e){
        var key=String.fromCharCode(e.keyCode);
        if(!(key>=0&&key<=9))$(this).val($(this).val().substr(0,$(this).val().length-1));
        var value=$(this).val();
        if(value.length==2||value.length==5)$(this).val($(this).val()+'/');
    });
    

    this is the code that you may need

    here is the fiddled code

提交回复
热议问题