Free Puzzle Questions with Answer using Java, C#, JavaScript and PHP

JavaScript - Validation

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <script language="JavaScript" type="text/javascript">
        function Validate(){
            if(document.myForm.txtFullname.value == ""){
                alert("Please enter fullname first");
                return false;
            }
            else if(document.myForm.txtEmail.value == ""){
                alert("Please enter email first");
                return false;
            }
            //recommeded to use regex for email validation
            else if(document.myForm.txtEmail.value.lastIndexOf(".") == -1){
                alert("Please enter email correctly");
                return false;
            }
            else if(document.myForm.selectCountry.value == "-"){
                alert("Please select country first");
                return false;
            }
            else{
                return true;
            }

        }
    </script>
</head>
<body>
    <form name="myForm" onsubmit="Validate()">
        <table>
            <tr>
                <td>Fullname</td>
                <td><input type="text" name="txtFullname" /></td>
            </tr>
            <tr>
                <td>Email</td>
                <td><input type="email" id="txtEmail" name="txtEmail" /></td>
            </tr>
            <tr>
                <td>Country</td>
                <td>
                    <select name="selectCountry">
                        <option value="-">-</option>
                        <option value="Ethiopia">Ethiopia</option>
                        <option value="US">US</option>
                        <option value="Canada">Canada</option>
                        <option value="Britain">Britain</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td><button> Sumbit Record</button></td>
                <td></td>
            </tr>
        </table>
    </form>
</body>
</html>