Home>

Please tell me the simplest check of fields to fill, so if by clicking on the "Register" button without updating the page! Next to the field that is not filled withdrawn "Fill in please field", etc. other fields.

  • Answer # 1

    please a simple example Check form "on the fly"

  • Answer # 2

    please a simple example Check form "on the fly"

  • Answer # 3

    HTML

    <
    Form id= "Form" Method= "POST" Action= "handler" >
            ≪
    Div >
                ≪
    Label >
    Name <
    /label >
                ≪
    INPUT TYPE= "TEXT" NAME= "FIRSTNAME" />
    ≪
    BR />
            ≪
    /div >
            ≪
    Div >
                ≪
    INPUT TYPE= "submit" value= "submit" />
            ≪
    /div >
        ≪
    /Form >
    

    Use JQuery Form Plugin

    <
    Script Type= "text /javascript" src= "https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" >
    ≪
    /script >
    ≪
    script type= "text /javascript" src= "js /jQuery.form.js" >
    ≪
    /script >
    ≪
    Script Type= "text /javascript" src= "js /jQuery.validate.js" >
    ≪
    /script >
    ≪
    Script Type= "Text /JavaScript" src= "js /form.js" >
    ≪
    /script >
    

    Last JS titled Form.js

    <
    script >
        $ ('Document'). Ready (Function () {
                    $ ('# Form'). Validate (
                    {
                        //Rules for verification
                        Rules: {
                            FIRSTNAME: {
                                REQUIRED: TRUE,
                                MINLENGTH: 2,
                                MaxLength: 30.
                                }
                        }
                        //Displayed messages in violation of the relevant rules
                        Messages: {
                            "FIRStName": {
                                Required: "Fill out this field",
                                MINLENGTH: "From 2 to 30 characters",
                                MaxLength: "From 2 to 30 characters"
                            }
                        }
                        //Specify the handler
                        SubmitHandler: FUNCTION (FORM) {
                            $ (Form) .ajaxSubmit ({
                                Target: '#PreView',
                                SUCCESS: FUNCTION () {
                                    $ ('# Contact_form'). SlideUp ("Fast", Function () {
                                    $ (this) .before ($ ("<
    Div id= 'Checkmark' >
    ≪
    img src= 'img /check.png' >
    ≪
    P >
    Your application is accepted! ≪
    /P >
    ≪
    /div >
    ") .delay (6000));
                                     }
                                     ) .Delay (6000) .slidedown ('Fast', Function () {$ (this) .prev (). Remove ();});
                                     $ ("# Form"). Clearform ();
                                    }
                                })
                                }
                            });
                        });
    ≪
    /script >
    

    css

    Form Div {
        Position: relative;
    }
    Form Label.error {
        Position: Absolute; Top: 32px; Left: 310px;
        font: 14px /20px tahoma;
        Padding: 5px 10px;
        Color: #FFF;
        Background: # F00;
        width: 140px;
        Float: Right;
        z-index: 1000;
        TEXT-ALIGN: CENTER;
        Display: Block;
        BORDER: 1PX SOLID # AF0000;
        -WebKit-Border-Radius: 5px;
       -Moz-Border-Radius: 5px;
       Border-Radius: 5px;
    }
    
  • Answer # 4

    HTML

    <
    Form id= "Form" Method= "POST" Action= "handler" >
            ≪
    Div >
                ≪
    Label >
    Name <
    /label >
                ≪
    INPUT TYPE= "TEXT" NAME= "FIRSTNAME" />
    ≪
    BR />
            ≪
    /div >
            ≪
    Div >
                ≪
    INPUT TYPE= "submit" value= "submit" />
            ≪
    /div >
        ≪
    /Form >
    

    Use JQuery Form Plugin

    <
    Script Type= "text /javascript" src= "https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" >
    ≪
    /script >
    ≪
    script type= "text /javascript" src= "js /jQuery.form.js" >
    ≪
    /script >
    ≪
    Script Type= "text /javascript" src= "js /jQuery.validate.js" >
    ≪
    /script >
    ≪
    Script Type= "Text /JavaScript" src= "js /form.js" >
    ≪
    /script >
    

    Last JS titled Form.js

    <
    script >
        $ ('Document'). Ready (Function () {
                    $ ('# Form'). Validate (
                    {
                        //Rules for verification
                        Rules: {
                            FIRSTNAME: {
                                REQUIRED: TRUE,
                                MINLENGTH: 2,
                                MaxLength: 30.
                                }
                        }
                        //Displayed messages in violation of the relevant rules
                        Messages: {
                            "FIRStName": {
                                Required: "Fill out this field",
                                MINLENGTH: "From 2 to 30 characters",
                                MaxLength: "From 2 to 30 characters"
                            }
                        }
                        //Specify the handler
                        SubmitHandler: FUNCTION (FORM) {
                            $ (Form) .ajaxSubmit ({
                                Target: '#PreView',
                                SUCCESS: FUNCTION () {
                                    $ ('# Contact_form'). SlideUp ("Fast", Function () {
                                    $ (this) .before ($ ("<
    Div id= 'Checkmark' >
    ≪
    img src= 'img /check.png' >
    ≪
    P >
    Your application is accepted! ≪
    /P >
    ≪
    /div >
    ") .delay (6000));
                                     }
                                     ) .Delay (6000) .slidedown ('Fast', Function () {$ (this) .prev (). Remove ();});
                                     $ ("# Form"). Clearform ();
                                    }
                                })
                                }
                            });
                        });
    ≪
    /script >
    

    css

    Form Div {
        Position: relative;
    }
    Form Label.error {
        Position: Absolute; Top: 32px; Left: 310px;
        font: 14px /20px tahoma;
        Padding: 5px 10px;
        Color: #FFF;
        Background: # F00;
        width: 140px;
        Float: Right;
        z-index: 1000;
        TEXT-ALIGN: CENTER;
        Display: Block;
        BORDER: 1PX SOLID # AF0000;
        -WebKit-Border-Radius: 5px;
       -Moz-Border-Radius: 5px;
       Border-Radius: 5px;
    }