validate a field

Hello!

This is my code:

In my form
onValidate
if( {date_2}==’’ ){
sc_error_message(“This field is empty”);
}

but the code doesn’t work.
I try empty( {date_2} )

In my DB the field date_2 is NULL
How do I can validate that I have not written anything in the field?

Thks

Re: validate a field

Have a look at:
http://brian.moonspot.net/null-isset-php

You have to check for empty and/or null.

Regards,
Scott.

Re: validate a field

Nop.
I try with === before and doesn’t work

Anyway I need to know if the html field is ==’’ or !=’’
In others fields (like text fields in DB) the IF works fine, but date fields (in DB) doesn’t work.

to see what happens…

without typing in the field
In my form
onValidate
sc_error_message("value date: "{date_2});

and return - value date: null

typing in the field (ex. 10/10/2010)
In my form
onValidate
sc_error_message("value date: "{date_2});

and return - value date: 10/10/2010

I try with javascript, but i need validate other fields in event onValidate

Re: validate a field

As mentioned, the url lists several ways to check for a field. using ==,=== will only check if the field is ‘’ and does not check for null.

You can use is_null, or isset.

The difference of == vs === is that === checks that the type is the same and is not related to null.

Regards,
Scott.

If you read date from a file and one line comes whit 2017-02-31 as date that is not a valid date, Who can’t you capture this error or any not valid date?