i want to get error message but didn’t get in validation of html form with jquery
تبليغيرجى شرح بإيجاز لمإذا تشعر أنك ينبغي الإبلاغ عن هذا السؤال.
it works but didn’t get desired answer and pls make changes in this code and pls explain
> <link rel=”stylesheet”
> href=”https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css”>
>
> <!– jQuery library –>
> <script src=”https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js”>
>
> </script>
>
> <!– Popper JS –>
> <script src=”https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js”>
>
> </script>
>
> <!– Latest compiled JavaScript –>
> <script src=”https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js”>
>
> </script>
> <script type=”text/javascript”>
> $(“document”).ready(function(){
> $(“#usercheck”).hide();
> $(“#passcheck”).hide();
>
> var user_err=”true”;
> var upass_err=”true”;
>
>
> $(“#username”).keyup(function(){
> username_check();
> });
> $(“#passcheck”).keyup(function(){
> password_check();
>
> });
> function password_check(){
> var pass_value=$(“password”).val();
> if (pass_value.length==””||”pass value length<6″)
> {
> $(“#passwordmessage”).show();
> $(“#passwordmessage”).html(“**please fill the password having length >6”);
> $(“#passwordmessage”).focus();
> $(‘#passwordmessage’).css (“color”,”red”);
> pass_err = false;
> return false;
> }
>
>
> else{
> $(‘#passwordmessage’).hide();
> }
>
>
> }
> function username_check() {
> var user_value=$(“username”).val();
> if(user_value.length==”0″)
> {
> $(“#usermessage”).show();
> $(“#usermessage”).html(“**please fill valid name “);
> $(“#usermessage”).focus();
> $(“#usermessage”).css(‘color’,’red’);
> pass_err=’false’;
> return false;
> }
> else {
> $(“#usemessage”).hide();
> }
>
>
> }
>
> $(‘#btnsubmit’).click(function(){
>
> user_err = true;
> pass_err = true;
>
>
> username_check();
> password_check();
>
> if((user_err == true ) && (pass_err == true) )
> {
> return true;
> }
> else
> {
> return false;
> }
>
> });
>
> });
> </script>
>
>
>
>
>
> <script src=”https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.0/jquery.min.js”>
</script>
> <body>
> <!–<div class=”Registration page”>
> <h1>Registration page</h1
> <form action=”#” name =
> –>
>
>
> <div class=”login-form”>
> <h1>LOGIN PAGE</h1>
> <form action=”#” name =”form1″ id =”form1″ method=”post”>
>
>
> <label for=”username” ><b>Username:</b></label><br>
> <input type=”text” id=”Username” placeholder=”Enter name” name=”Username”
autocomplete=”off”>
> < br><br>
> <div id=”show_error”></div><br>
> <label for=”password”><b>Password:</b></label><br>
> <input type=”password” id =”password” placeholder=”Enter password” name=”password”
> autocomplete=”off” ><br><br>
> <div id=”show-error”></div>
> <!–<button type=”submit”>Login</button><br><br>–>
> <input type = “submit” id = “btnsubmit” value = “LOGIN” name = “btnsubmit” ><br>
> <span>
> <input type=”checkbox” id= “remember” name=”remember ” value=”remember me”>
> <label for =”checkbox” name=”checkbox” >Remember me</label>
> </span>
>
>
> <span class=”password”>Forget <a href=”#” >Password ?</a></span><!–work as to scroll up –>
>
> </form>
> </div>
> </body>
أضف إجابة