The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Validate Class
#1
Hi Everybody,

Did someone make an implementation for validate fields kind "DATE" in Validate Class ?

How can I do it?

Thanks


  Reply
#2
No. And we probably need to overhaul that class. I keep running into things it doesn't do. I do my date validation in html.

Code:
<input type="date"

  Reply
#3
Here is the validation rule that I use. Feel free to adjust the date format to something else.

Code:
case 'valid_date':
Code:
$d = DateTime::createFromFormat('Y-m-d', $value);
Code:
if(($d && $d->format('Y-m-d') == $value)) $valid = true;
Code:
else $valid = false;
Code:
if ($valid != true) {
Code:
$this->addError(["{$display} must be a date with a format of YYYY-MM-DD.", $item]);
Code:
}
Code:
break;
  Reply
#4
Awesome! Thanks for this!
  Reply
#5
I have this and a few others posted in the modifications forum, in one of faguss' threads.

https://userspice.com/forums/topic/valid...vements-2/

They were during your busy months so you may have missed them!
  Reply
#6
Wow, really Thanks for help me

I do some tests with "<input type="date", but this doesn't work under Mozilla Firefox and I don't like use javascript a lot for validate fields in form I think that best validations are in back end like Validate Class.

Thank you for all.


  Reply
#7
Right. Yeah. JS is not the best way to do it. The newest validate class is in the 4.3 alpha and was just updated a few minutes ago.

https://github.com/mudmin/UserSpice43dev...lidate.php
  Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)