[SOLVED] İnput Type Problem

Answered
0
0

When I set a textbox input type number , textbox maxlength is not work , and textbox accept  like “e” ,”+”,”-“,”x” caracters.

This is big problem for us

Thanks

 

 

 

  • You must to post comments
Best Answer
0
0

You can:

  1. Use MaskedTextBox
  2. Use NumericUpDown
  3. Attach a javascript event handler to handle “keypress”, see attached screenshot.
  4. Attach a javascript event handle in code:
 this.textBox1.AddClientEventListener("keypress", @"
 var e = arguments[0];
 if ('0123456789'.indexOf(e.getKeyIdentifier()) === -1)
 e.stop();
 ");

HTH

 

Attachment
  • You must to post comments
0
0

Thank you very much luca

AddClientEventListener code it is work , I want  also backspace and delete press permission it is possible ?
  • Levie (ITG)
    Hi, this might be useful: https://stackoverflow.com/questions/9906885/detect-backspace-and-del-on-input-event . Detecting the keyCode / charCode of delete / backspace.
  • HSoft
    • HSoft
    • Jun 14, 2019 - 9:44 am
    this.textBox1.AddClientEventListener(“keydown”, @”function(event) { const key = event.key; if (key === ‘Backspace’ || key === ‘Delete’) { return false;}}”); this code no work , I dont it
  • HSoft
    • HSoft
    • Jun 14, 2019 - 9:50 am
    this code is work thanks for helps this.textBox1.AddClientEventListener(“keypress”, @”var e = arguments[0];if (‘0123456789’.indexOf(e.getKeyIdentifier()) === -1 && e.getKeyIdentifier() != ‘Backspace’)e.stop();”);
  • You must to post comments
0
0

It’s how it works in the browser.

The InputType property of the TextBox allows you to use the native implementation of the different types. It is not a Wisej widget – it’s exactly as the browser implements it.

https://www.w3schools.com/html/html_form_input_types.asp

It’s different on each browser and on each OS.

  • HSoft
    • HSoft
    • Jun 12, 2019 - 4:00 pm
    Is there a solution to doing this ?
  • HSoft
    • HSoft
    • Jun 12, 2019 - 4:01 pm
    This code not wok on wisej private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { e.Handled = !char.IsDigit(e.KeyChar) && !char.IsControl(e.KeyChar); }
  • Luca (ITG)
    It works. The handled property is set to true and you will find it in the different handlers related to KeyPress. What you cannot do is change the keyboard behavior of a browser on a client from server code. Wisej makes it too easy to forget that the browser and server are different machines.
  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.