I have implemented an igNumericEditor on my page.
When the users pressed the Enter Button the form closes.
How can I catch the Enter key to prevent my page to close.
(I have seen: https://ko.infragistics.com/community/forums/f/ignite-ui-for-javascript/67254/submitting-with-enter-key )
but this solution seems not to be working on igNumericEditor.
my implementation looks like
$("#number_working_hours").igNumericEditor( { minValue: 100, maxValue: 9000, dataMode: 'int', groupSeparator: String.fromCharCode(65279), regional: 'de', hideEnterKey: true, keydown: function(evt, ui) { return false; // return ui.key !== 13; } });
Hello Karl-Heinz,
After investigating this further, I determined that your request could be achieved in two ways, depending on when Enter should be suppressed. If pressing Enter anywhere on the page should disable submitting the form, the following lines of code could be used:
$(document).ready(function(){
$("#document").keydown(function(event){
if(event.keyCode == 13) {
event.preventDefault();
return false;
}
});
If pressing Enter only within the igNumericEditor should disable submitting the form, however, pressing Enter in the other input fields not, the id of the input, bound to the igNumericEditor, should be set, instead of “#document”. I have prepared a sample, demonstrating the second way, this request could be achieved.
Please let me know if you need additional information regarding this matter.
Regards,
Monika Kirkova,
Infragistics
igNumericEditor.rar
Hi Monika,
thanks for that quick help!
Your appended example works properly :-)
Whereas your code above seems not to be working.
I modified that code a little bit to make it work:
$("form").keydown(function(event) { if (event.keyCode == 13) { event.preventDefault(); return false; } });
As I have some more edit controls on my site it is very handsome to use one javascript function for all controls.
thanks a lot and
best regards
Karl-Heinz