Yuvaraj, The code above is not going to work, it generates errors in the console and the logic is backwards ...
- if (inp.val().length > 0) {
- alert("BOx Empty");
- $("#Box1").focus();
- }
I'm not sure what inp.val is supposed to be. You declare it with a capital V then use it with a lowercase.
If the length is greater than 0 it means there is something in the box.
The shorthand way to do this would be:
- $("#amount").focusout(function(){
- if (!$(this).val()) {
- alert("This field is required");
- $(this).focus();
- }
- });
Saumitra, you also had a "#" in front of the first line of your code above when it should be a $.
Dave