Prevent space in maskedEditBox

How do I prevent a space from being entered in a masked edit box?   This is VB.NET
LVL 1
HLRosenbergerAsked:
Who is Participating?
 
Russ SuterConnect With a Mentor Commented:
Is this a Windows Forms project or a Web Application project?

The former solution involves an event handler. The latter would need Javascript. In either case there is a solution.

Since you mentioned VB.NET I'm going to assume it's a web application. In that case, here's a jQuery snippet that will do the trick for you:
$("#[YourControlId]").on({
  keydown: function(e) {
    if (e.which === 32)
      return false;
  },
  change: function() {
    this.value = this.value.replace(/\s/g, "");
  }
});

Open in new window

0
 
Éric MoreauSenior .Net ConsultantCommented:
what is your mask?
0
 
HLRosenbergerAuthor Commented:
Sorry.  it is not WEB app.  and I got it working using your concept - in keypress, if it's a space, I set it to NULL. Thanks!
0
 
HLRosenbergerAuthor Commented:
Thanks!
0
All Courses

From novice to tech pro — start learning today.