Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                
    <div class="dx-viewport demo-container">
        <form id="form" action="your-action">
            <div class="dx-fieldset">
                <div class="dx-fieldset-header">Credentials</div>
                <div class="dx-field">
                    <div class="dx-field-label">Email</div>
                    <div class="dx-field-value">
                        <div id="email-validation"></div>
                    </div>
                </div>
                <div class="dx-field">
                    <div class="dx-field-label">Password</div>
                    <div class="dx-field-value">
                        <div id="password-validation"></div>
                    </div>
                </div>
                <div class="dx-field">
                    <div class="dx-field-label">Confirm Password</div>
                    <div class="dx-field-value">
                        <div id="confirm-password-validation"></div>
                    </div>
                </div>
            </div>
            <div class="dx-fieldset">
                <div class="dx-fieldset-header">Personal Data</div>
                <div class="dx-field">
                    <div class="dx-field-label">Name</div>
                    <div class="dx-field-value">
                        <div id="name-validation"></div>
                    </div>
                </div>
                <div class="dx-field">
                    <div class="dx-field-label">Date of birth</div>
                    <div class="dx-field-value">
                         <div id="date-validation"></div>
                    </div>
                </div>
            </div>
            <div class="dx-fieldset">
                <div class="dx-fieldset-header">Billing address</div>
                <div class="dx-field">
                    <div class="dx-field-label">Country</div>
                    <div class="dx-field-value">
                        <div id="country-validation"></div>
                    </div>
                </div>
                <div class="dx-field">
                    <div class="dx-field-label">City</div>
                    <div class="dx-field-value">
                        <div id="city-validation"></div>
                    </div>
                </div>
                <div class="dx-field">
                    <div class="dx-field-label">Address</div>
                    <div class="dx-field-value">
                        <div id="address-validation"></div>
                    </div>
                </div>
                <div class="dx-field">
                    <div class="dx-field-label">Phone <i>(optional)</i></div>
                    <div class="dx-field-value">
                        <div id="phone-validation"></div>
                    </div>
                </div>
                <div id="check"></div>
            </div>
            <div class="dx-fieldset">
                <div id="summary"></div>
                <div id="button"></div>
            </div>
        </form>

    </div>

              
            
!

CSS

              
                #summary {
    padding-left: 10px;
    margin-top: 20px;
    margin-bottom: 10px;
}

#button {
    display: block;
}

              
            
!

JS

              
                $(function(){
    var maxDate = new Date();
    maxDate.setYear(maxDate.getYear() - 21);
        
    var sendRequest = function(value) {
        var validEmail = "test@test.com";
        var d = $.Deferred();
        setTimeout(function() {
            d.resolve(value === validEmail);
        }, 1000);
        return d.promise();
    }

    $("#summary").dxValidationSummary({ });
    
    $("#email-validation").dxTextBox({})
        .dxValidator({
            validationRules: [{
                type: "required",
                message: "Email is required"
            }, {
                type: "email",
                message: "Email is invalid"
            }, {
                type: "async",
                message: "Email is already registered",
                validationCallback: function(params) {
                    return sendRequest(params.value);
                }
            }]
    });
    
    $("#password-validation").dxTextBox({
        mode: "password"
    }).dxValidator({
        validationRules: [{
            type: "required",
            message: "Password is required"
        }]
    });
    
    $("#confirm-password-validation").dxTextBox({
        mode: "password"
    }).dxValidator({
        validationRules: [{
            type: "compare",
            comparisonTarget: function(){ 
                var password = $("#password-validation").dxTextBox("instance");
                if(password) {
                    return password.option("value");        
                }
            },
            message: "'Password' and 'Confirm Password' do not match."
        },
        {
            type: "required",
            message: "Confirm Password is required"
        }]
    });
    
    $("#name-validation").dxTextBox({
        value: "Peter"
    }).dxValidator({
        validationRules: [{
            type: "required",
            message: "Name is required"
        }, {
            type: "pattern",
            pattern: /^[^0-9]+$/,
            message: "Do not use digits in the Name."
        }, {
            type: "stringLength",
            min: 2,
            message: "Name must have at least 2 symbols"
        }]
    });
    
    $("#date-validation").dxDateBox({
        invalidDateMessage: "The date must have the following format: MM/dd/yyyy"
    }).dxValidator({
            validationRules: [{
                type: "required",
                message: "Date of birth is required"
            }, {
                type: "range", 
                max: maxDate, 
                message: "You must be at least 21 years old"
            }]
    });
    
    $("#country-validation").dxSelectBox({
        dataSource: countries
    }).dxValidator({
        validationRules: [{
            type: "required",
            message: "Country is required"
        }]
    });
    
    $("#city-validation").dxTextBox({ })
        .dxValidator({
            validationRules: [{
                type: "required",
                message: "City is required"
            }, {
                type: "pattern",
                pattern: "^[^0-9]+$",
                message: "Do not use digits in the City name."
            }, {
                type: "stringLength",
                min: 2,
                message: "City must have at least 2 symbols"
            }]
    });
    
    $("#address-validation").dxTextBox({ })
        .dxValidator({
            validationRules: [{
                type: "required",
                message: "Address is required"
            }]
    });
    
    $("#phone-validation").dxTextBox({
            mask: "+1 (X00) 000-0000",
            maskRules: {
                "X": /[02-9]/
            },
            maskInvalidMessage: "The phone must have a correct USA phone format",
            useMaskedValue: true
        })
        .dxValidator({
            validationRules: [{
                type: "pattern",
                pattern: /^\+\s*1\s*\(\s*[02-9]\d{2}\)\s*\d{3}\s*-\s*\d{4}$/,
                message: "The phone must have a correct USA phone format"
            }]
    });
    
    $("#check").dxCheckBox({
        value: false,
        text: "I agree to the Terms and Conditions"
    }).dxValidator({
        validationRules: [{
            type: "compare",
            comparisonTarget: function(){ return true; },
            message: "You must agree to the Terms and Conditions"
        }]
    });
    
    $("#form").on("submit", function(e) {
        DevExpress.ui.notify({
            message: "You have submitted the form",
            position: {
                my: "center top",
                at: "center top"
            }
        }, "success", 3000);
        
        e.preventDefault();
    });
    
    $("#button").dxButton({
        text: "Register",
        type: "success",
        useSubmitBehavior: true
    });
    
    
});

var countries = ['Afghanistan','Albania','Algeria','Andorra','Angola','Antigua and Barbuda','Argentina','Armenia','Australia','Austria','Azerbaijan','The Bahamas','Bahrain','Bangladesh','Barbados','Belarus','Belgium','Belize','Benin','Bhutan','Bolivia','Bosnia and Herzegovina','Botswana','Brazil','Brunei','Bulgaria','Burkina Faso','Burma','Burundi','Cambodia','Cameroon','Canada','Cape Verde','Central African Republic','Chad','Chile','China','Colombia','Comoros','Democratic Republic of the Congo','Republic of the Congo','Costa Rica','Ivory Coast','Croatia','Cuba','Cyprus','Czech Republic','Denmark','Djibouti','Dominica','Dominican Republic','East Timor','Ecuador','Egypt','El Salvador','Equatorial Guinea','Eritrea','Estonia','Ethiopia','Fiji','Finland','France','Gabon','The Gambia','Georgia','Germany','Ghana','Greece','Grenada','Guatemala','Guinea','Guinea-Bissau','Guyana','Haiti','Honduras','Hungary','Iceland','India','Indonesia','Iran','Iraq','Republic of Ireland','Israel','Italy','Jamaica','Japan','Jordan','Kazakhstan','Kenya','Kiribati','North Korea','South Korea','Kuwait','Kyrgyzstan','Laos','Latvia','Lebanon','Lesotho','Liberia','Libya','Liechtenstein','Lithuania','Luxembourg','Republic of Macedonia','Madagascar','Malawi','Malaysia','Maldives','Mali','Malta','Marshall Islands','Mauritania','Mauritius','Mexico','Federated States of Micronesia','Moldova','Monaco','Mongolia','Montenegro','Morocco','Mozambique','Namibia','Nauru','Nepal','Kingdom of the Netherlands','New Zealand','Nicaragua','Niger','Nigeria','Norway','Oman','Pakistan','Palau','State of Palestine','Panama','Papua New Guinea','Paraguay','Peru','Philippines','Poland','Portugal','Qatar','Romania','Russia','Rwanda','Saint Kitts and Nevis','Saint Lucia','Saint Vincent and the Grenadines','Samoa','San Marino','São Tomé and Príncipe','Saudi Arabia','Senegal','Serbia','Seychelles','Sierra Leone','Singapore','Slovakia','Slovenia','Solomon Islands','Somalia','South Africa','South Sudan','Spain','Sri Lanka','Sudan','Suriname','Swaziland','Sweden','Switzerland','Syria','Tajikistan','Tanzania','Thailand','Togo','Tonga','Trinidad and Tobago','Tunisia','Turkey','Turkmenistan','Tuvalu','Uganda','Ukraine','United Arab Emirates','United Kingdom','United States','Uruguay','Uzbekistan','Vanuatu','Vatican City','Venezuela','Vietnam','Yemen','Zambia','Zimbabwe'];
              
            
!
999px

Console