Support Article
Validation not triggered when non-numeric values entered
SA-33577
Summary
User configured ‘NUMBER’ in Presentations tab of an input field.
In Internet Explorer only, the operator do not see validation triggered when non-numeric values are entered.
When user enters Non-integer input, and tab-out, the system removes the value from the field.
Error Messages
Not Applicable
Steps to Reproduce
1. Take any of the following input control (pxNumber, Integer, Text input, pxCurrency) and refer any decimal property.
2. Go to Presentation tab and set Editable input mode to NUMBER.
3. Remove Ui-Kit7 ruleset from Application Ruleset stack.
4. During run-time, enter non-numeric input and tab-out , user observes that the input gets vanished without any validation error.
But if Ui-Kit7 ruleset is present, user will not able to enter any non-numeric input.
Root Cause
For Input type Number, Chrome browser restricts to enter alphabets in textinput, but Internet Explorer allows alphabets.
As it is a browser restriction.
The below two PDN article provides more information on this behaviour:
- https://pdn.pega.com/release-note/text-input-control-number-type-does-not-validate
- https://pdn.pega.com/support-articles/pega-controls-pxnumber-pxcurrency-ie-browser-issue
Resolution
To achieve the same restricted functionality as in Chrome browser, use below code in RULE-HTML-FRAGMENT USERWORKFORM that restricts all the number typed integers in Internet Explorer browser:
<script>
pega.u.d.attachOnload(function(){
var numberElements=document.querySelectorAll(".ie input[type='number']");
debugger;
for(var i=0;i<numberElements.length;i++){ console.log("number");
numberElements[i].addEventListener('keydown', function(e) {
console.log("inside");
var key = e.keyCode ? e.keyCode : e.which;
if (!( [8, 9, 13, 27, 46, 110, 190].indexOf(key) !== -1 ||
(key == 65 && ( e.ctrlKey || e.metaKey ) ) ||
(key >= 35 && key <= 40) ||
(key >= 48 && key <= 57 && !(e.shiftKey || e.altKey)) ||
(key >= 96 && key <= 105)
)) e.preventDefault();
});
}});
</script>
Published March 5, 2017 - Updated October 8, 2020
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.