CSS translation series-(for web form verification, use jquery for animation verification)

Source: Internet
Author: User

Source of the original article. comrades who have experience in project development may encounter issues such as form verification, check the validity of user input, and filter out illegal user input, the traditional pop-up warning box-based method does not meet the needs of users for visual appearance. How to prompt users in a more friendly way is a problem that should be considered by UI designers.

 

The technology is quite simple: when a user presses the submit button, verification occurs, and all illegal input fields will shake. Below is a very simple form. I will not explain the structure style of the form, here I only focus on animation effects.

 

<ul>    <li class="first">        

Working principle: When you press the submit button, jquery will get all empty input fields. if at least one empty input field exists, the animation is applied to the input field.

$("#signup").click(function() {    var emptyfields = $("input[value=]");    if (emptyfields.size() > 0) {        emptyfields.each(function() {            // animation goes here        });    }}); 

 

Let's take a look at how to create a simple animation. We need to move each input field 10px to the left, move 10px to the right, repeat this action once, and set it back to their original position.

$("#signup").click(function() {    var emptyfields = $("input[value=]");    if (emptyfields.size() > 0) {        emptyfields.each(function() {            $(this).stop()                .animate({ left: "-10px" }, 100).animate({ left: "10px" }, 100)                .animate({ left: "-10px" }, 100).animate({ left: "10px" }, 100)                .animate({ left: "0px" }, 100)                .addClass("required");        });    }});

Remember: static verification feedback cannot replace this type of animation verification. Once verification fails, every illegal input field needs to be clearly marked. This special effect allows users to capture the user's attention, here you can get more verification articles

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.