Page 1 of 1

ADDT javascript validation and server side validation

Posted: 2015-11-03 10:10
by piripacchio
Hi all,
I need to migrate/integrate form validation made with ADDT with some server side validation.
What is the best way to do this with ADDT?
Does "Throw error" server behaviour cover this problem?
Example:
I need to check a date entered by the user. The date is valid if it's at least 7 days before the current date.
How can I validate it, server side with ADDT?
I would create a variable in php that contains the computed date (today - 7 days) and then use it in a "throw error" server behaviour using the Build condition feature: if $computed_date > $entered_date.
Does it works?
Obviously there should be better ways to do this.
Can you point in the right direction for server side validation with ADDT?

Thanks in advance for any suggestion.

tony

Re: ADDT javascript validation and server side validation

Posted: 2015-11-03 11:32
by piripacchio
ok,
I just made some tests and it seems to work.

Here what I've done.

- I've set a session variable to get the actual date less 7 days:

Code: Select all

if (!session_id()) session_start();
  $date1= date("Y-m-d", time() - 60*60*24*8);
  $_SESSION['sess_date'] = $date1;
  session_register("sess_date");
Then I've set a throw error trigger to check the entered form date against the date stored in the session:
Built condition: {form_date} > {SESSION.sess_date}

It seems to work as exptected.
Can this be hacked by bypassing javascript validation?

Is there something else that I should be aware of?

TIA

tony