AJAX Submit and error message

Hi All,

I am doing Final project Assignment 8 which involve use of ajax.

I learn that without using ajax for a button everything is working fine.

(1)Red background error message which showing "Please fix the existing error before proceed" able to pop up.(section a in the screen )

(2)Error message for the particular input "Check In Date Should Not Earlier Than Today" also able to show out(section b in screen)

(3).Focus is on the first invalid input.

                                                                      Screen 1

However after applying AJAX submit method for the button, i learn that

(1)Error message for the particular input "Check In Date Should Not Earlier Than Today" does not show out(section b in screen).Only the input is highlighted.Refer to screen 2

(2).The focus is not on the first invalid input.Refer to screen 2

(3).The error message only shows out when i click on the input.Refer to screen 3

(4).And i learn that if i click on the button again, everything is fine.All the error message able to show out.It is just that only the first time it is not working.

                                                                         Screen 2

                                                                       Screen 3

Below is the flow.

Can anyone advise on this?Help


The code, last image, seems strange, as it seems the error branch will execute only when the form is valid... This would explain why it "works" with a submit, but not with an ajax submit...

If form valid is true, than it should go down, not to left... As it is, when there are errors, you are not sending the message nor focusing on first input with error...

Try swapping the if branches to fix it.


Eduardo Jauch

hi Johnson,

When the callback server action (like save, etc) is called, the preparation action of the screen is recalled.

I have an interesting case, where i have a check box and it is related with a boolean value. Whenever the checkbox is checked then the Save action is called, the checkbox becomes unchecked. This is not what the user wants. 

So, you need to provide another variable to see whether the form is valid or invalid.



Hi Eduardo,

Thanks for your help.I make a larger screen shoot as below perhaps the screen is not large enough to see.The flows works fine without ajax.By applying ajax method , i need to revise the logic?I try to debug with or without AJAX , the logic works as expected.The only different is that the input has no error message besides it.

Hi Barong,

Thanks for your help.The input still does not has the error message besides after i assign the form.Is valid to a local variable.


Does anyone has idea on this?



Didn't notice the not. This is not usual. Usually, the true branch is for the "everything is ok".

In this case, in the branch true, where you enter if the form is not ok, change the order of the actions. 

The ajax refresh must come before the input focus, if I still remember, or the effect will be lost when the form is refreshed, as they will be executed in the browser in the order they appear in the logic.


Eduardo Jauch


Hi Johnson,

Make sure your Ajax Refresh for BookingForm is executed before you call Input_FocusFirstInvalid action. Actually, the best place for you to put that Ajax Refresh is probably right before your 'not Form.Valid?' If tool.

Hi Eduardo,

It is working now!! Thanks so much, you are always helpful !!

Thanks Jorge  too

hi Lim, the order is the trouble:

it is okay:

with this order:




Thanks Barong