When I try to use masking on the textbox for credit card format, I am having trouble entering a hyphen. It seems that the validation does not accept dashes as I only checked for numbers. Any help would be appreciated. Thank you.
<script>
function fn_AllowonlyNumeric(s, e) {
var theEvent = e.htmlEvent || window.event;
var key = theEvent.keyCode || theEvent.which;
key = String.fromCharCode(key);
var regex = /[0-9]/;
if (!regex.test(key)) {
theEvent.returnValue = false;
if (theEvent.preventDefault)
theEvent.preventDefault();
}
}
</script>
<dx:BootstrapTextBox AutoPostBack="true" AutoCompleteType="Disabled" ClientInstanceName="ttxtSozNo" ID="KartNumarasi" MaxLength="19" runat="server" CssClasses-Input="form-control valid" aria-invalid="false" OnTextChanged="KartNumarasi_TextChanged" >
<ClientSideEvents KeyPress="function(s,e){ fn_AllowonlyNumeric(s,e);}" />
<CssClasses Input="form-control valid" />
<ValidationSettings ErrorText="" RequiredField-IsRequired="True" SetFocusOnError="True" RegularExpression-ValidationExpression="^[a-zA-Z0-9'@&#.\s]{6,16}$">
<RegularExpression ErrorText="" />
<RequiredField ErrorText="" IsRequired="True" />
</ValidationSettings>
<MaskSettings Mask="0000-0000-0000-0000" />
</dx:BootstrapTextBox>