Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/330.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 文本框asp.net中用户输入的自动日期格式_C#_Asp.net_Date_Textbox - Fatal编程技术网

C# 文本框asp.net中用户输入的自动日期格式

C# 文本框asp.net中用户输入的自动日期格式,c#,asp.net,date,textbox,C#,Asp.net,Date,Textbox,我想有一个自动日期格式时,用户输入的日期。到目前为止,我得到的是价格值的自动逗号: <script type="text/javascript" language="javascript"> function Comma(Num) { Num += ''; Num = Num.replace(',', ''); Num = Num.replace(',', ''); Num = Num.replace(',', ''); Num = Num.replace(

我想有一个自动日期格式时,用户输入的日期。到目前为止,我得到的是价格值的自动逗号:

<script type="text/javascript" language="javascript">

function Comma(Num) {
    Num += '';
    Num = Num.replace(',', ''); Num = Num.replace(',', ''); Num = Num.replace(',', '');
    Num = Num.replace(',', ''); Num = Num.replace(',', ''); Num = Num.replace(',', '');
    x = Num.split('.');
    x1 = x[0];
    x2 = x.length > 1 ? '.' + x[1] : '';
    var rgx = /(\d+)(\d{3})/;
    while (rgx.test(x1))
        x1 = x1.replace(rgx, '$1' + ',' + '$2');
    return x1 + x2;
}

</script>

函数逗号(Num){
Num+='';
Num=Num.replace(',','');Num=Num.replace(',','');Num=Num.replace(',','');
Num=Num.replace(',','');Num=Num.replace(',','');Num=Num.replace(',','');
x=分割数('.');
x1=x[0];
x2=x.长度>1?'.+x[1]:'';
var rgx=/(\d+)(\d{3})/;
while(rgx.测试(x1))
x1=x1.替换(rgx,'$1'+','+'$2');
返回x1+x2;
}

你能给我一些类似的代码,用户可以在其中选择一个日期,或者当他们键入日期时,它会自动添加一个斜杠之类的东西吗?

你可以尝试html标记输入


或者您可以尝试AjaxControlToolkit



jQuery UI日期选择器-默认功能
$(函数(){
$(“#日期选择器”).datepicker();
});
日期:


您已经标记了c#和javascript。您希望使用哪种语言?C#有一个蒙面文本框选项,可以为您自动设置格式。@Takarii这不是一个仅用于winforms的控件吗?@PaoloDuhaylungsod为什么不使用jquery datepicker控件?并使用它的日期格式化功能。@PaoloDuhaylungsod你说得对。完全忘记了:(
    <html lang="en">
<head>
  <meta charset="utf-8">
  <title>jQuery UI Datepicker - Default functionality</title>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
  <link rel="stylesheet" href="/resources/demos/style.css">
  <script>
  $(function() {
    $( "#datepicker" ).datepicker();
  });
  </script>
</head>
<body>

<p>Date: <input type="text" id="datepicker"></p>


</body>
</html>