When using masking on the textbox, I need to enter a hyphen in credit card format. But since I only checked for numbers, I guess the validation does not accept dashes. Thanks for your help.
<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>
I believe that you do not need the client-side javascript validation code/handler, which contradicts the declarative mask settings, at all:
<dx:BootstrapTextBox ...>
<%--<ClientSideEvents KeyPress="function(s,e){ fn_AllowonlyNumeric(s,e);}" />--%>
...
<MaskSettings Mask="0000-0000-0000-0000" />
</dx:BootstrapTextBox>
Check out the related sample - to see how it works.