Micro Focus QTP (UFT) Forums
How to run script written in Javascript using QTP 9.0 - 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: How to run script written in Javascript using QTP 9.0 (/Thread-How-to-run-script-written-in-Javascript-using-QTP-9-0)



How to run script written in Javascript using QTP 9.0 - scrapspace - 02-25-2009

Hello Everyone,

In my web page, I have an Input field(button) with event (onclick) calling a javascript function.
This javascript checks if any mandatory field (like text input for name) is not filled.

My Problem : When I made a record, if I left blank mandatory field, and click on Button, the event is not recorded.
Remark : If I enter value in mandatory field, it’s OK.


//My input fields
Code:
<input type="text" runat="server" id="name">
<input type="button" name="submit" onclick="jcpAction();">

//My javascript

function cpAction()
{
   var success =true;
   var nameinput = document.getElementById('name');
   if(nameinput.value== '')
   {
      success = false;      
   }
   return success;
}

any suggestions??
Why QTP is not picking up above written Javascript?


RE: How to run script written in Javascript using QTP 9.0 - tarunlalwani - 02-26-2009

Insert the click yourself and see what happens. If that does not help then look at the below article

http://knowledgeinbox.com/articles/qtp/settings/when-to-change-qtp-web-replaytype-setting/