javascript - Ngx引导日期选择器的最大类型数?
问题描述
如何限制 ngx bootstrap 的日期选择器类型 例如,如果我输入 04/25/199332132132 它是有效的....
<input type="text" placeholder="04/25/1993" class="d-inline input-item form-control font-weight-bold text-center datepicker-input mrg "
autocomplete="off" formControlName="date" aria-label="date" name="date"
bsDatepicker [bsConfig]="{ isAnimated: true }"/>
解决方案
作为添加readonly
到输入元素的一种方式,因此它只能从日期选择器中选择。
<input type="text" placeholder="04/25/1993" class="d-inline input-item form-control font-weight-bold text-center datepicker-input mrg " readonly
autocomplete="off" formControlName="date" aria-label="date" name="date"
bsDatepicker [bsConfig]="{ isAnimated: true }"/>
或添加 onkeydown="this.value = (this.value.length > 9) ? this.value.slice(0, 9) : this.value;"
禁用超过 10 个字符
推荐阅读
- php - 每分钟检查一次数据库,然后发送通知
- angular - 以 Angular 6 形式初始化 Square iframe 的问题
- python - 仅当将某些内容添加到列表中时如何打印?
- csv - 从多个 csv 文件创建 libsvm 用于 xgboost 外部内存训练
- r - 将日期列表转换为 R 中的另一种格式?
- regex - 尝试替换记事本++中的一些文本
- python - 在数据帧上迭代 re.split()
- javascript - 在控制台中,如果 html 标签呈紫色闪烁,这是否意味着它正在用 javascript 重新呈现?
- c++ - 包含指向类中方法的指针的结构模板和数组
- konvajs - 如何从组中分离形状?