full-journalist-82607
02/03/2023, 7:44 AMfull-journalist-82607
02/03/2023, 7:47 AMbright-gpu-74537
02/03/2023, 8:07 AMbright-gpu-74537
02/03/2023, 8:09 AMbright-gpu-74537
02/03/2023, 8:22 AMbright-gpu-74537
02/03/2023, 8:22 AMhaxe
mainForm.onSubmitStart = function(_) {
// clear any errors
}
mainForm.onInvalidData = function(event:ValidatorEvent) {
// show some errors
trace("invalid data");
for (field in mainForm.invalidFields) {
trace("invalid field: ", field.id, mainForm.invalidFieldMessages.get(field));
}
}
mainForm.onValidData = function(event:ValidatorEvent) {
// all good
trace("valid data");
}
mainForm.onSubmit = function(_) {
trace("submitted");
}
You dont actually need to do any of this either, the default behaviour for the form is that it will shake and highlight invalid fields and cancel submission, the above is just if you want to customize it and show what is the problembright-gpu-74537
02/03/2023, 8:23 AMmainForm.submit()
)bright-gpu-74537
02/03/2023, 8:27 AMrefined-greece-48002
02/03/2023, 9:52 AMrefined-greece-48002
02/03/2023, 9:55 AM<button id="my_button" disabled />
Just purely for readabilitybright-gpu-74537
02/03/2023, 9:59 AMbright-gpu-74537
02/03/2023, 10:00 AMrefined-greece-48002
02/03/2023, 10:01 AMrefined-greece-48002
02/03/2023, 10:11 AMrefined-greece-48002
02/03/2023, 10:11 AMbright-gpu-74537
02/03/2023, 10:12 AMbright-gpu-74537
02/03/2023, 10:13 AMhaxe
showNotification7.onClick = function(_) {
var type = NotificationType.Info;
if (notificationType.selectedItem.text == "Info") {
type = NotificationType.Info;
} else if (notificationType.selectedItem.text == "Error") {
type = NotificationType.Error;
} else if (notificationType.selectedItem.text == "Warning") {
type = NotificationType.Warning;
}
NotificationManager.instance.addNotification({
title: "Notification With Type",
body: "Notification types are a quick way to add generalized styling to a notification",
type: type
});
}
refined-greece-48002
02/03/2023, 10:13 AMbright-gpu-74537
02/03/2023, 10:14 AMbright-gpu-74537
02/03/2023, 10:15 AMhaxe
typedef NotificationData = {
var body:String;
@:optional var title:String;
@:optional var icon:String;
@:optional var actions:Array<String>;
@:optional var expiryMs:Int;
@:optional var type:NotificationType;
@:optional var styleNames:String;
}
bright-gpu-74537
02/03/2023, 10:19 AMbright-gpu-74537
02/03/2023, 10:23 AMbright-gpu-74537
02/03/2023, 10:24 AMbright-gpu-74537
02/03/2023, 11:29 AMbright-gpu-74537
02/03/2023, 11:29 AMambitious-knife-25690
02/03/2023, 11:43 AMbright-gpu-74537
02/03/2023, 1:15 PMambitious-knife-25690
02/03/2023, 1:27 PMambitious-knife-25690
02/03/2023, 1:27 PMbright-gpu-74537
02/03/2023, 1:29 PM