This topic is locked

message confirm/cancel on date_diff

2/6/2020 6:43:56 PM
PHPRunner General questions
L
laamari author

Hi

I'm looking for a way to alerte user by message beforesave if the field content (date)= today

if click confirm the record go to saving

if click cancel the record is aborted.

thanks

A
acpan 2/6/2020

Something like this:
In the JavaScript OnLoad event for the Edit or Add page:

Note: Replace DateEntered to your actual field name.



// replace DateEntered to your actual field name
this.on('beforeSave', function(formObj, fieldControlsArr, pageObj)

{
// get the field data via Javascript control object API

var ctrlDateEntered = Runner.getControl(pageid, 'DateEntered');

var DateEntered = ctrlDateEntered.getValue();

var d = new Date()

var bool = (d.toDateString() === DateEntered.toDateString());

alert(bool +" => Date Entered:" + DateEntered.toDateString() + " | Today Date:" + d.toDateString());



if (bool)

{

if (confirm('Save record with date ' + DateEntered.toDateString()+ '?') )

{

return true;

}

else

{

Runner.delDisabledClass ( pageObj.saveButton );

return false;

}

}

})

;


Check the online manual for ask before save example: Ask before save Example

and Get value from control object