Micro Focus QTP (UFT) Forums
problem with javascript - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: problem with javascript (/Thread-problem-with-javascript)



problem with javascript - meuline - 10-31-2008

Hello,

In my web page, I have an Input field with two events (onkeyup and onchange) calling a javascript function.
This javascript checks if the size’s value is 5. If so, the form is submit and the same screen is display.

My problem : When I made a record, if I write 5 characters, the event is not recorded.
Remark : If I write 2 characters and I quit the field it’s OK.


My input field
Code:
<input type="text" name="codePostal" onkeyup="javascript:cpAction();" onchange="javascript:cpAction();">


My javascript
Code:
function cpAction(){
            var cp = formulaire.elements['codePostal'].value
            if( ((cp.length == 5) && (estValideCodePostal(cp))) || (cp.length == 0) ){
                        aValider = false;
                        formulaire.elements['reqCode'].value='display';
                        formulaire.submit();
            }
}



Thank's