我有一个视图,要求用户将他们的生日输入到文本框中.
我正在使用UI-Utils的mask指令.
我的视图中有这个输入元素:
<input ui-mask="99/99/9999" placeholder="MM/DD/YYYY" type="text" name="uBirthdate" ng-model="user.birthdate" required/>
Run Code Online (Sandbox Code Playgroud)
在我的控制器中,我将范围设置为
myApp.controller('HomeCtrl', function ($scope, myService){
$scope.user = registerService.getCurrentUser();
$scope.submit = function () {
//do something with $scope.user.birthdate
};
}
});
Run Code Online (Sandbox Code Playgroud)
我的问题是,在我的控制器中,birthdate属性包含来自输入的值没有屏蔽字符所以输入
11/20/1980在视图中变为11201980$ scope的属性
如何确保在控制器中使用有效的屏蔽日期?仅供参考,此日期将作为JSON发送到我的服务器的POST请求中.
我在测试了我的程序后意识到软件应用程序管理开发票我注意到以下错误:我在sqlserver中的表包含:price numeric(6,2)我程序的用户输入价格为555.00是好的.但是当他把555555放错了,所以我需要指定一个掩码,其中尾数是可选的0到999,小数部分是可编程的2或3根据用户的选择,我使用的是JQuery Masked输入插件,我有没有找到好的正则表达式,请帮助,我正在使用jsp/servlet.
我使用@ @角度9.0.7,@ngneat/spectator@5.3.1(用玩笑),Inputmask@5.0.3在一个项目中,一切工作的应用程序时,我跑ng serve,甚至ng build,但是当我尝试运行测试套件的失败@Pipe使用Inputmask:
@Pipe:
import { Pipe, PipeTransform } from '@angular/core';
import Inputmask from 'inputmask';
@Pipe({
name: 'appSomePipe',
})
export class SomePipe implements PipeTransform {
transform(value: string): string {
return Inputmask.format(value, {
jitMasking: true,
mask: '1111-1',
});
}
}
Run Code Online (Sandbox Code Playgroud)
@Spec:
import { createPipeFactory, SpectatorPipe } from '@ngneat/spectator/jest';
import { SomePipe } from './some.pipe';
describe('SomePipe', () => {
let spectator: SpectatorPipe<SomePipe>;
const …Run Code Online (Sandbox Code Playgroud) 我想限制p:inputMask为数字只,而我从试图提出的解决方案:
但它们都没有奏效.我试过这两种方式:
<p:inputMask id="userNo" maxlength="2" mask="9?9999" />
Run Code Online (Sandbox Code Playgroud)
和
<p:inputMask id="userNo" maxlength="2" >
<pe:keyFilter regEx="/[0-9_]/i"/>
</p:inputMask>
Run Code Online (Sandbox Code Playgroud) 我有一个简短形式的电话号码TextField.然后我想掩盖这个表单字段,如(0)xxx xxx xx xx.
我正在尝试使用react -UI的react-input-mask插件.但是,如果我想更改输入值,则不会更新我的主TextField.
<TextField
ref="phone"
name="phone"
type="text"
value={this.state.phone}
onChange={this.onChange}
>
<InputMask value={this.state.phone} onChange={this.onChange} mask="(0)999 999 99 99" maskChar=" " />
</TextField>
Run Code Online (Sandbox Code Playgroud)
实际上,我找不到任何使用Material-UI屏蔽的文档.我试图找出如何使用其他插件.
我有以下设置。我的面具会出现,但是当我输入它时,它只是跳到行尾,我不太确定我在这里做错了什么。我尝试将所有道具放入父组件中并通过扩展传递它们,但这不起作用。如果有人能给我一个关于首先在哪里调试的想法,我可以提供更多调试,我会这样做。
提前致谢
import React from "react"
import { useForm } from "react-hook-form"
import MaskedInput from "react-input-mask"
const Quote = () => {
const { register, handleSubmit, watch, errors } = useForm();
const [tel, setTel] = React.useState("");
render(
<MaskedInput
mask="(780) 000-0000"
alwaysShowMask
onChange={(e) => setTel(e.target.value)}
value={tel}
name={data.title}
>
{(inputProps) => (
<input
ref={register({
required: true,
pattern: /^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$/im,
})}
value={inputProps.tel}
name={inputProps.name}
{...inputProps}
/>
)}
</MaskedInput>
);
};
Run Code Online (Sandbox Code Playgroud) 我需要在表单的输入字段中添加一些掩码.我尝试在下面的代码中插入jQuery.js和jQuery.MaskedInput.js显示:
<h:head>
<h:outputScript name="jquery-1.6.4.min.js" library="javascript" />
<h:outputScript name="jquery.maskedinput-1.3.js" library="javascript" />
<script>
jQuery(function($){
$("#date").mask("99/99/9999");
$("#phone").mask("(999) 999-9999");
$("#tin").mask("99-9999999");
$("#ssn").mask("999-99-9999");
});
</script>
<title>TITLE</title>
</h:head>
<h:body>
<h:form id="form">
<h:inputText id= "date" />
</h:form>
</h:body>
Run Code Online (Sandbox Code Playgroud)
到目前为止没什么.
更新
使用BalusC,$("[id='form:phone']").mask("(99) 9999-9999");它工作正常!(多谢,伙计).但是我需要在数据表中应用这个掩码:
<script>
jQuery(function($){
$("input.phones").mask("(999) 999-9999");
});
</script>
<title>TITLE</title>
Run Code Online (Sandbox Code Playgroud)
<h:form id="form">
<h:panelGrid columns="3">
<h:outputLabel for="phones" value="Telefone(s) :" />
<h:dataTable id="phones" value="#{profile.user.userPhones}" var="item">
<h:column>
<h:inputText id= "phone" value="#{item.phone}" />
</h:column>
<h:column>
<h:commandButton value="Remove" action="#{profile.removePhone}"/>
</h:column>
<h:column>
<rich:message id="m_phone" for="phone" />
</h:column>
</h:dataTable>
<h:commandButton …Run Code Online (Sandbox Code Playgroud) 我有一个带有数字输入类型的EditText元素.我不希望用户能够输入0作为第一个数字.我可以使用XML强制执行此操作吗?
这是我目前的情况:
<EditText
android:id="@+id/main_edt_loan"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:background="@drawable/sample_editbox"
android:ems="10"
android:layout_margin="10dip"
android:inputType="number"
android:hint=""
android:ellipsize="start"
android:maxLines="1"
android:imeOptions="actionNext"
android:textSize="18dip"
android:gravity="center"
android:digits="0123456789"
android:maxLength="10"
android:textColor="#000000"/>
Run Code Online (Sandbox Code Playgroud) 我正在使用RobinHerbots输入掩码,我怎样才能使2个小数点像22.30或2.15?比如'currency'在输入掩码上设置但没有逗号(自动生成基于值长度)和货币符号.以下是我尝试过的内容,但遗憾的是,这些内容都不起作用,有什么帮助,建议,想法,线索,建议吗?
$(document).ready(function(){
$(".decimal").inputmask('decimal',{rightAlign: true});
$(".currency").inputmask('currency',{rightAlign: true });
$(".custom1").inputmask({ mask: "**[.**]", greedy: false, definitions: { '*': { validator: "[0-9]" } }, rightAlign : true });
$(".custom2").inputmask({ 'alias' : 'decimal', rightAlign: true, 'groupSeparator': '.','autoGroup': true });
$(".custom3").inputmask({ 'alias' : 'decimal', 'mask' : "**[.**]", rightAlign: true});
});Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.inputmask/3.2.6/jquery.inputmask.bundle.min.js"></script>
<input type="text" class="decimal" /><br>
<input type="text" class="currency" /><br>
<input type="text" class="custom1" /><br>
<input type="text" class="custom2" /><br>
<input type="text" class="custom3" value="0" /><br>Run Code Online (Sandbox Code Playgroud)
我有电话号码的HTML输入框.
我使用InputMask的格式输入860000000在下面8 600 00 000打字时.
$(window).load(function()
{
var phones = [{ "mask": "# ### ## ###"}, { "mask": "# ### ## ###"}];
$('#phone').inputmask({
mask: phones,
greedy: false,
definitions: { '#': { validator: "[0-9]", cardinality: 1}} });
});
Run Code Online (Sandbox Code Playgroud)
我也使用HTML模式检查数字是否86以及总共9位数,但是InputMask它停止工作,并且无法以任何方式实现它:
<label for="phone" class="first-col">Mobile No.:</label>
<input type="text" id="phone" placeholder="8 600 00 000" required pattern="(86)\d{7}" />
Run Code Online (Sandbox Code Playgroud)
如果有效,CSS添加绿色边框:
input:required:valid {
box-shadow: 0 0 5px #5cd053;
border-color: #28921f;
}
Run Code Online (Sandbox Code Playgroud)
你有什么想法吗?
input-mask ×10
jquery ×4
javascript ×3
html ×2
jsf-2 ×2
reactjs ×2
regex ×2
android ×1
angular ×1
angular-test ×1
angularjs ×1
forms ×1
jsf ×1
mask ×1
material-ui ×1
primefaces ×1
richfaces ×1