Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 74
  • Last Modified:

Prevent space in maskedEditBox

How do I prevent a space from being entered in a masked edit box?   This is VB.NET
0
HLRosenberger
Asked:
HLRosenberger
  • 2
1 Solution
 
Russ SuterCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now