Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • JohnAss 18 posts 128 karma points
    7 days ago
    JohnAss
    0

    Creating a property editor - how to validate before Save

    I have the following js:

    angular.module("umbraco").controller("NullableIntController", function ($scope) {
    
    $scope.regex = /^[-+]?[0-9]+$/;
    
    });
    

    And the html:

    <div ng-controller="NullableIntController">
    <input type="text" ng-model="model.value" ng-pattern="regex" />
    </div>
    

    The first time I tried to save a content-node with this I wasn't allowed.

    However, now it just lets me save even though I type in letters. The value ends up being null if it's not matching the regex - but I can still hit the Save button.

    Im so confused as to how it worked once and now it's just not anymore.

    How can I make sure it wont allow me to save when the pattern is incorrect?

    Already looked at this post: https://our.umbraco.com/forum/extending-umbraco-and-using-the-api/85517-custom-property-editor-input-type-number-doesnt-show-value

    But it didn't really help

Please Sign in or register to post replies

Write your reply to:

Draft