-
1. Re: Have a field acting like Excel Cell
Magus069 Apr 24, 2014 7:59 AM (in response to Magus069)Hi Rob,
I found the solution so if anyone else is looking for something similar,
you can set everything in the validate event of a text field preferably..
if (this.rawValue != null){
// Validate the equation
var regExpression = new RegExp("\\d+(\\.\\d+)*|[\\(\\)\\+\\-\\*\\/]"); // Create a new Regular Expression Object.
// Set the regular expression to look for any equation's operators and numbers
var result = regExpression.test(this.rawValue); // Test the string
// If it fits regexp
if (result == true) {
// all is good and execute the equation
this.rawValue = Math.eval(this.rawValue);
true;
}
else{
// fail the validation.
xfa.host.messageBox("Please insert a valid equation to calculate.", "Information", 2);
this.rawValue = "";
false;
}
}

