JQuery Example
Screen shot
jQuery Form Validation

<html>

<head>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

</head>

<body>

<!-- Html form -->

<form name="frm" action="" method="post">

Full Name<input type="text" id="fullname"><br>

<div id="namemsg" style="color: red;"></div>


Email<input type="text" id="email"><br>

<div id="emailmsg" style="color: red;"></div>


<input type="submit" id="btnsubmit">


</form>

</body>

<!-- Jquery validation code-->

<script type="text/javascript">

$(document).ready(function() {

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


$("#namemsg").empty(); 

$("#emailmsg").empty(); 

    var str;

var fullname = $("#fullname").val();

var email = $("#email").val();

var regEx = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;

    var validEmail = regEx.test(email);  

    var str=true;

if(fullname==''){

$("#namemsg").html("Name must be fill out");

    str=false;

}


if(email==''){

$("#emailmsg").html("Email must be fill out");

    str=false;

}

    else if(!validEmail){

$("#emailmsg").html("Enter Valid Email");

    str=false;

}


return str;

});

});

</script>

</html>