Copy link to clipboard
Copied
I am completely new to doing javascript, and I am trying to complete a form to show or hide a particular text field. I know there are posts on performing the hide/show condition with a checkbox using javascript; and if all else fails I will use this.
However, I am wondering if it is possible for hiding or showing a text field using a date picker field? For example, If the date field is blank, I want the text field to show, and if a date is selected the text field goes away. Then, if the date field is cleared out, the text field reappears. Make sense?
Thank you,
TJ
No, it will not hide the date field. it will hide the other field, if you enter its name in the part in quotes where I put "Name of other field"...
Copy link to clipboard
Copied
Sure, that's possible.
As the custom Validation script of the date field enter the following:
this.getField("Name of other field").display = (event.value=="") ? display.visible: display.hidden;
Copy link to clipboard
Copied
Thank you Try67. This will hide my date field, however, I am looking for hiding a different text field when a date is selected.
So, I though if I did the following as an if statement, might do what I am looking for.
if(the.getField("Date6_af_date").display=(event.value==""));
{
this.getField("Text1").display = display.hidden;
}
else
{
this.getField("Text1").display = display.visible;
}
But I get a Syntax Error. So I am missing something
Copy link to clipboard
Copied
No, it will not hide the date field. it will hide the other field, if you enter its name in the part in quotes where I put "Name of other field"...
Copy link to clipboard
Copied
I am sorry, I realized I put the wrong field name in the parentheses. It works great. Thank you very much.
Copy link to clipboard
Copied
Try this:
if (this.getField("Date6_af_date").value == "");
{
this.getField("Text1").display = display.hidden;
}
else
{
this.getField("Text1").display = display.visible;
}
Copy link to clipboard
Copied
Thank you JR for your recommendation. Try67's worked correctly once I realized I made a mistake when I entered the field name.
Copy link to clipboard
Copied
I am trying your code but I want my field CoverCF not visible when PlatesOrdered is less than ten.
I tried the below, but get a syntex error:
if (this.getField("PlatesOrdered").value < "10");
{
this.getField("CoverCF").display = display.visible;
}
else
{
this.getField("CoverCF").display = display.hidden;}
Copy link to clipboard
Copied
In the first line, remove the semicolon.
Not sure what you want to happen but the way you write script, it will display "CoverCF" field even when "PlatesOrdered" field is empty or 0 too.
Copy link to clipboard
Copied
I now have this script, but getting a syntax error. I am trying to have text boxes cover the fields behind it so they cannot be seen till the orders get to 10
if(this.getField("PlatesOrdered").value < v10 )
this.getField("CoverCF").display = display.visible;
} else { this.getField("CoverCF").display = display.hidden;
Copy link to clipboard
Copied
Remove two curly brackets. You should change v10 to 10.
Copy link to clipboard
Copied
Here is what I am putting in the validation, but the text box remains visible.
if (this.getField("PlatesOrdered").value < 10)
this.getField("CoverCF").display = display.display;
else this.getfield("CoverCF").display = display.hidden
Copy link to clipboard
Copied
Change display.display to display.visible and in last line change this.getfield to this.getField.
If you use script as validation in "PlatesOrdered" field you can also simplify it like this:
this.getField("CoverCF").display = Number(event.value) < 10 ? display.visible : display.hidden;
Copy link to clipboard
Copied
thanks