AnswerBun.com

function not getting called onkeypress event of the input element

I am trying to allow only numeric input in a textbox…For this I am writing a code as follows:

'<input type="text" id="txtFlexibility" class="form-control input-sm" onkeypress="return isNumberKey(event)" />'

protected isNumberKey(event): boolean{
const charCode = (event.which) ? event.which : event.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57))
    return false;
return true;}

isNumberKey(event) is not getting called….
Please suggest an workaround….

SharePoint Asked by Nidhi Maheshwari on January 3, 2021

0 Answers

Add your own answers!

Related Questions

Library Search Permissions

1  Asked on December 26, 2020 by joe-fedorowicz

 

Exceeds Threshold

4  Asked on December 25, 2020

     

SPListItemCollection to Dictionary

1  Asked on December 24, 2020 by k-jones

     

Use SharePoint as front end for access

2  Asked on December 22, 2020 by dominica

   

Save Modal Dialog Field Value to Refresh Page DIV

1  Asked on December 22, 2020 by aurumpotabile

   

_x0020_ Not Working in AJAX

1  Asked on December 19, 2020 by bigchungus

       

Edit Hidden Item in List

1  Asked on December 18, 2020 by decave

       

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved.