PDA

View Full Version : How can I kill a function if a inputTextField is empty



fs_tigre
February 21st, 2010, 01:51 PM
Hi,

I have a small aplication with two inputTextFields and a button, when the button is pressed it triggers a function that calculates the value in the two text fields, and everything is fine but when the textFileds are empty which is the default value and the button is press I get an error (Error: Error #1502: A script has executed for longer than the default timeout period of 15 seconds.)

My question is how can I detect if the inputTextFileds are empty and some how kill the main function ?

function Name: calculate
Input Text Field 1: partL_txt
Input Text Field 2: partW_txt
Button Name: enterBtn

Thanks a lot!

BoppreH
February 21st, 2010, 02:29 PM
Inside the function "calculate", wrap all code inside this:


if (partL_txt.text.length > 0 && partW_txt.text.length > 0) {
// makes calculations here
}

This will check if the fields are empty before executing anything.

fs_tigre
February 21st, 2010, 08:54 PM
Great it worked! I just added the return statement and it did the trick.


if (partL_txt.text.length > 0 && partW_txt.text.length > 0) {
// makes calculations here
return;
}

THANKS A LOT