Skip to main content
April 6, 2020
Answered

How do I check the date form that without input?

  • April 6, 2020
  • 2 replies
  • 612 views

There are two "Date Field".
If there is no input in one of them, I want to reset the other "Text Field", but I can't.

 

The following JavaScript is embedded in the "Text Field" that I want to reset.

 

In the example below, the "Text Field" is "AA_A".
The "Date Field" are "Day_Start" and "Day_Set".

 

By the way, "Text Field" is numeric.

And also readonly.

 

var AAAa = this.getField("AA_A");

var AAAb = AAAa.value;

 

var DayBa = this.getField("Day_B");
var DayBb = util.scand("yyyy/mm/dd", DayBa.value);
var DayBc = DayBb.valueOf();

 

var DayCa = this.getField("Day_C");
var DayCb = util.scand("yyyy/mm/dd", DayCa.value);
var DayCc = DayCb.valueOf();

 

All of the following do not work.

 

(1)

if (!DayBc || !DayCc ){this.resetForm("AA_A");};

 

(2)

if (DayBc == null || DayCc == null ){this.resetForm("AA_A");};

 

(3)

if (DayBc == undefined || DayCc == undefined ){this.resetForm("AA_A");}

 

(4)

if (DayBc == '' || DayCc == '' ){this.resetForm("AA_A");}

 

(5)

if (DayBc == 0 || DayCc == 0 ){this.resetForm("AA_A");}

 

Actually, I tried various other methods that I could come up with, but they were all useless.

For example,  AAAb = ''  on the right...

 

Thanking you for your advance.

This topic has been closed for replies.
Correct answer Bernd Alheit

Try this:

 

if (this.getField("Day_B").value == "" || this.getField("Day_C").value == "")
event.value = "";

2 replies

Bernd Alheit
Community Expert
Bernd AlheitCommunity ExpertCorrect answer
Community Expert
April 6, 2020

Try this:

 

if (this.getField("Day_B").value == "" || this.getField("Day_C").value == "")
event.value = "";

April 7, 2020

great! Your suggestion was correct!

It worked properly.

 

I will try to memorize this.

 

But I still don't understand why it doesn't work with other code.

For example: 

 

var AAAa = this.getField("AA_A");

var AAAb = AAAa.value;

 

var DayBa = this.getField("Day_B");
var DayBb = DayBa.value;

 

var DayCa = this.getField("Day_C");
var DayCb = DayBa.value;

 

 

if (DayBb == '' || DayCb == '' ){this.resetForm("AA_A");}

if (DayBb == '' || DayCb == '' ){AAAb == '';}

 

In my understanding, these codes feel like they have the same meaning as your suggestion.

Bernd Alheit
Community Expert
Community Expert
April 6, 2020

To reset the field use:

event.value = "";

April 6, 2020

Thank you for your prompt reply.
I sincerely thank you, including the last time's another question.
Any way, I am lucky guy because you. Thank you !

 

But unfortunately, your advice is something I have already tried.
This code cannot reset in my this case.

 

However, and anyway, I'm really not good at "Date code" and there are many things I don't understand.

 

So I thought it was the cause.

But as I guess from your advice of this, there may be a problem elsewhere...