There is a requisite in the "Delivery Date" document. His user fills himself. How to put a ban on choosing a date earlier than the current date?

I tried to compare it with the current date with the error output, but my code also does not work:

&НаКлиенте Процедура ДатаПриИзменении(Элемент) Дата = Элементы.ДатаДоставки.ТекущиеДанные; Если Дата().Сравнить(ТекущаяДата()) = -1 Тогда Сообщить ("Ввод раньше текущей даты запрещен!"); КонецЕсли КонецПроцедуры 
  • Please note that the user can probably transfer local time on a computer and enter data with any date. - Kromster
  • Yes, there is a probability .... then I will have to try to compare with the current date of the server, I will try the proposed code on the server - Elena

2 answers 2

Perhaps you incorrectly request a date value from the form. This is how it works for me:

 &НаКлиенте Процедура ДатаПриИзменении(Элемент) ДатаДоставки = Объект.ДатаДоставки; Если НачалоДня(ДатаДоставки) < НачалоДня(ТекущаяДата()) Тогда Сообщить ("Ввод раньше текущей даты запрещен!"); КонецЕсли; КонецПроцедуры 

If you need to display not only a warning, but not to save the document, then you need to insert this check into the ПередЗаписью procedure:

 Процедура ПередЗаписью(Отказ, РежимЗаписи, РежимПроведения) Если НачалоДня(ДатаДоставки) < НачалоДня(ТекущаяДата()) Тогда Сообщить ("Ввод раньше текущей даты запрещен!"); Отказ = Истина; КонецЕсли; КонецПроцедуры 
  • thank! I can try to apply only after a few hours. I will first note as answered. Can you tell me how to do it when the user selects a date, make the dates that are not currently active? Is it possible - Elena
  • Yes, now it worked)))))) - Elena
 Если Дата() < ТекущаяДата() Тогда Сообщить ("Ввод раньше текущей даты запрещен!"); КонецЕсли;