Copy link to clipboard
Copied
I don't know why this isn't working.
I entered the following in custom calculation script in the RegHrs1 text field, but I'm not getting the alert when the Shift Premium checkbox is ticked. What am I doing wrong??
var a = this.getField("ShiftPrem1").value;
var b = this.getField("RegHrs1").valueAsString;
if(a=="Off") event.value=b;
else if (a=="Yes") event.value="";
if ( (b!=="") && (a=="Yes") ) app.alert("Please enter hours first",0);
1 Correct answer
This should be enough...
var a = this.getField("ShiftPrem1").value;
var b = event.value;
if ( (b=="") && (a=="Yes") ) app.alert("Please enter hours first",0);
this.getField("RegHrs1").setFocus();
I have added the focus back to the field.
@try67 is there a way to set back focus to self without having to use this.getField (" ") ?
Copy link to clipboard
Copied
Okay, it works when I enter hours in the text field and then click on the checkbox, but that's the opposite of what I need. I need the alert if there are no hours entered in RegHrs1 text field when the user checks the Shift Premium box. Please help me, I don't know what to do 🙂
Copy link to clipboard
Copied
You're accessing the field's previous value. Change this line:
var b = this.getField("RegHrs1").valueAsString;
To:
var b = event.value;
Copy link to clipboard
Copied
I entered the following Custom Calculation script in the RegHrs1 text field, but it still only shows the alert when text is filled in RegHrs, not if the user checks the box if the text field is blank. What am I missing?
var a = this.getField("ShiftPrem1").value;
var b = event.value;
if(a=="Off") event.value=b;
else if (a=="Yes") event.value="";
if ( (b!=="") && (a=="Yes") ) app.alert("Please enter hours first",0);
Copy link to clipboard
Copied
I hope that makes sense, I only want the alert to show if the user checks the Shift Prem checkbox without entering hours in the RegHrs text field, but it only pops up when hours have been entered.
Copy link to clipboard
Copied
This should be enough...
var a = this.getField("ShiftPrem1").value;
var b = event.value;
if ( (b=="") && (a=="Yes") ) app.alert("Please enter hours first",0);
this.getField("RegHrs1").setFocus();
I have added the focus back to the field.
@try67 is there a way to set back focus to self without having to use this.getField (" ") ?
Copy link to clipboard
Copied
Fantastic!! That's works!! Thank you so much!!
Copy link to clipboard
Copied
The last line is probably not needed.
Copy link to clipboard
Copied
Only if you reject the value in the Validation event.
Copy link to clipboard
Copied
Thank you both so much!! I really appreciate it!!!

