Skip to content

An editable field component which can validate input and POST asynchronously

Notifications You must be signed in to change notification settings

AqoviaElements/async-editable-field

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bower version Build status Published on webcomponents.org Gitter

<async-editable-field>

<async-editable-field> is an editable field component which can validate input and POST asynchronously

<async-editable-field
    id="myField"
    name="fieldName"
    value="Field Value" 
    url="http://httpstat.us/200?sleep=750"
    save-text="Update"
    cancel-text="Cancel">
</async-editable-field>

<script>
    var editableField = document.querySelector('async-editable-field#myField');

    editableField.successResponseCallback = function(response, xhr) {
      alert("[" + xhr.status + "] Success: " + response);
    };

    editableField.errorResponseCallback = function(response, status) {
      alert("[" + status + "] Response: " + response);
    };
        
    editableField.validationFunction = function(value) {
        var reg = new RegExp(/^\d+$/);
        if (!reg.test(value)) {
            this.warningText = "Value must only contain numbers!";
            return false;
        }
        return true;
    };
</script>

About

An editable field component which can validate input and POST asynchronously

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages