Jump to content

I Need Javascript To Check A Field Is Empty Or Not

Recommended Posts

There is a table contains 5 file fields that users can submit files (images) to our table.


In the report form (details page), I set 5 html blocks to display them one by one with responsive tag (width=70%) and they displayed finally and responsively.


I showed them in this way.

<img src "URL" width=70%"/>


However there is a problem comes. I need some JavaScript code to check and decide if I execute this html code. Otherwise there is a img icon showed if there is empty in that field


If there is a file, it will be executed.

If there is empty, it will not be executed.


Could anybody help


Thanks. Sam

Link to comment
Share on other sites

Hi Sam,


How are you doing?


I think, you can insert the following code to your HTML Blocks:

var firstfield = '[@field:file1]';
document.write("<img src='[@field:file1/]' width=70%/>");
document.write("<img src='DEFAULT URL' width=70%/>");

Insert your field instead of both [@field:file1] .

For me, it's better to use a Parameter picker and use the String format for the first line, and "File URL" for the "document.write" line.


I will be glad to hear if the code works or help, if it does not :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...