VALIDATION IN PHP OR JS

 MOBILE VALIDATAION

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title> </title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
</head>
<body>

    <div id="container">
        <label>Enter Mobile No: </label>
        <input type="text" id="phone" placeholder="Enter 10 digit mobile no.."><br>
        <small style="visibility: hidden;">Error MSg</small>
        <br><input type="submit" id="Submit" value="Click to Validate">
    </div>

<script type="text/javascript">
    
    $("document").ready(function(){

        $("#Submit").click(function(){

            const phoneVal = $("#phone").val();

            if(phoneVal===""){
                $("small").css("visibility","visible");
                $("small").css("color","red");
                $("small").html('Phone number cannot be blank');
            // setErrorMsg(phone,'Phone number cannot be blank');

            }else if(phoneVal.length != 10){
                $("small").css("visibility","visible");
                $("small").css("color","red");
                $("small").html('Not a valid phone number');
                // setErrorMsg(phone,'Not a valid phone number');

            }else if(isNaN(phoneVal)){

                $("small").css("visibility","visible");
                $("small").css("color","red");
                $("small").html('Please enter valid phone number');
                // setErrorMsg(phone,'Please enter valid phone number');

            }else if(phoneVal.charAt(0)!=9 && phoneVal.charAt(0)!=8 && phoneVal.charAt(0)!=7 && phoneVal.charAt(0)!=6){

                $("small").css("visibility","visible");
                $("small").css("color","red");
                $("small").html('Please enter valid phone number');
                // setErrorMsg(phone,'Please enter valid phone number');

            }
            else{
                $("small").css("visibility","visible");
                $("small").css("color","Green");
                $("small").html('** CONGRATULATIONS **');
                // setSuccessMsg(phone);

            }


        });


    });

</script>


</body>
</html>



Comments

Popular posts from this blog

Sahari

[[ ROYAL CAR ]] CHANGE PASSWORD - DYNAMIC BANNER - MULTIPLE IMAGE - LOGIN LOGOUT BACK BUTTON MIDDLEWARE STOP - MAIL DIRECTLY WITH FEEDBACK WITH SAVE IN SQL DB - ADMIN REPLY EXISTING MAILS - DYNAMICALLY CSS CHANGE

Linux Terminal