Alert on onValidateSuccess control form

Hi All,
What’s the best way to add a dialog box after a successful validation? sc_alert doesn’t work and echo doesn’t give me a the look I want.

Thanks,
Damian

What kind of an alert?.. if what you want is to send a message with something like “record inserted correctly” or somehting like that you can use the default msg in the application settings.

messages.png

Another option is to cheat a bit. In your OnValidate code section use Try-Catch blocks (standard PHP: See the manual about throwing and handling Exceptions: http://php.net/manual/en/language.exceptions.php) . At the end of the try block use the sc_alert macro to give the user the message. This requires, though, that if there are any application errors that you handle in code, they are to be handled by throwing exceptions. In the catch block you can then use sc_error_message to state the error to the user. Thus, the end of the Try block will only be reached if no errors are encountered, which means that OnValidateSuccess would be the next code to be executed.

In general if any code section contain more than just a few trivial lines of code, I always use try-catch block and throw for any errors that I check for. In the Catch block I then use sc_error_message or even my own message app if the sc_error_message / sc_alert is not allowed for in Scriptcase code section. A further advantage of using Try-Catch is that it also will catch other unforeseen errors.

If you want to basically show a message, then just do this:

echo “<script> alert(‘YOUR MESSAGE’);</script>”;