roattw Posted May 3, 2017 Report Share Posted May 3, 2017 I have a script forcing numeric characters only in a couple fields (thanks May Music). <script> function isNumberKey(evt){ var charCode = (evt.which) ? evt.which : event.keyCode if (charCode > 31 && (charCode < 48 || charCode > 57)) return false; return true; } document.getElementById('InsertRecordFIELD1').onkeypress =isNumberKey; </script> I had several fields like this so I cheated and created one script for each FIELDNAME (I know, I know, Im still learning :^). How could I combine all fields into that one script above? I tried this but it didnt work: document.getElementById('InsertRecordFIELD1','InsertRecordFIELD2','InsertRecordFIELD3') Quote Link to comment Share on other sites More sharing options...
Mathilda Posted May 17, 2017 Report Share Posted May 17, 2017 On 5/3/2017 at 3:31 PM, roattw said: I have a script forcing numeric characters only in a couple fields (thanks May Music). <script> function isNumberKey(evt){ var charCode = (evt.which) ? evt.which : event.keyCode if (charCode > 31 && (charCode < 48 || charCode > 57)) return false; return true; } document.getElementById('InsertRecordFIELD1').onkeypress =isNumberKey; </script> I had several fields like this so I cheated and created one script for each FIELDNAME (I know, I know, Im still learning :^). How could I combine all fields into that one script above? I tried this but it didnt work: document.getElementById('InsertRecordFIELD1','InsertRecordFIELD2','InsertRecordFIELD3') Just write two additional lines which will call function for each field: document.getElementById('InsertRecordFIELD1').onkeypress =isNumberKey; document.getElementById('InsertRecordFIELD2').onkeypress =isNumberKey; document.getElementById('InsertRecordFIELD3').onkeypress =isNumberKey; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.