@ashokrd2013 I've added some change to your patch to ensure that we're defining the JS vars before using them and to add some more spacing for readability. Great work!
Originally, this ticket also called out only one button having the red outline after the submit. I don't think it should be there at all. It seems like awkward UX and looks horrible ( to my color blind eyes anyway ). As such, I think we should stop it from being added to the button at all.
This is not going to make it before 4.9 RC ( the deadline for bugs is today ) so let's try to get that added to this patch and we'll aim for the next release.
I'm going to assign this to @ashokrd2013 but if anyone wants to work on it ( looking at you @piyush9100 :) ) please feel free to!