You can go through this
I made the the above changes like you both suggested.
But when I place the cursor in the second text-box without entering details in first text-box I get a alert box, after pressing the 'ok' button the cursor is still in second text-box but I want to make the cursor to come the first text-box because first text-box is not valid.
So, which way is better
1. Simply showing alert box on typing invalid input in each text-box and doing validation check once again for all text-boxes before submitting the form.
2. Making sure that user enter correct input in a text-box before he enters the second text-box.
Depends on your client's requirement.
In the past we have implemented both the scenarios mentioned by you for different clients.
But most of them went for the 1st approach.
Fewer clients went for the 2nd approach as user can become frustrated if not allowed to go anywhere on browser without valid input.