Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shake effect on text syntax in JQuery

I am trying to give shake effect on my input type text when validation fails. It is giving shake effect but I don't know how to change default value of direction, distance and times. Also I think I'm doing something wrong in storing value of textbox in variable a. Please tell me the correct syntax. Thank you.

<!DOCTYPE html>
<html>
    <head>
        <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
        <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
        <script>
            $(document).ready(function(){
                $("#submitBtn").click(function(){
                    $a = $("#userNameTxt").value;
                    if ($a != "text")
                    {
                        $("#userNameTxt").effect("shake");
                    }
                });
            });

        </script>

    </head>
    <body>
        <form action="#" >
        <input type="text" name="userNameTxt" id="userNameTxt" placeholder="username" />
        <br/>
        <input type="submit" value="submit" id="submitBtn" />
        </form>

    </body>
</html>
like image 318
Prodeep Chatterjee Avatar asked Feb 05 '26 09:02

Prodeep Chatterjee


1 Answers

Some thing like these options ??

 $("#button").click(function(){
         $(".target").effect( "shake", 
          {times:4}, 1000 );
      });

Here is shake effect fully explained

like image 136
Suresh Atta Avatar answered Feb 06 '26 23:02

Suresh Atta



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!