Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

303
Views
DevExpress ASP.NET TextBox Number or Character validation

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>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!