1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Keypress event handler

Discussion in 'C#' started by markyjj, Apr 25, 2006.

  1. markyjj

    markyjj New Member

    Am currently trying to create code that clears a text box after a message box is shown when a nonnumeric digit is entered. The code am using doesnt clear the text field as shown below:
    if(Char.IsDigit(e.KeyChar) == false)
    				txtStudID.Text = "";
                   MessageBox.Show("Please enter a numeric value to continue");
    Thanks for any help
    Last edited by a moderator: Apr 25, 2006
  2. shabbir

    shabbir Administrator Staff Member

    Does it show the message box.
  3. pradeep

    pradeep Team Leader

    Oh! A simple fix on line 7 would fix that, change line 7 to this

    if (document.layers || e.which) { pressedKey = e.which; }

Share This Page