0

Im having a problem in my forms in validating empty fields. When the user clicked the edit button and clear the input field then click the send button, there is no validation that’s happening. I’ve tried angularjs’s form validation but it seems not working. Here’s the live view Thanks

http://jsfiddle.net/5DMjt/920/

function ClickToEditCtrl($scope) {
$scope.name = "joe Doe";
$scope.email = "[email protected]";

$scope.enableEditor = function () {
    $scope.showEditor = true;
    $scope.editName = $scope.name;
    $scope.editEmail = $scope.email;

};

$scope.disableEditor = function () {
    $scope.showEditor = false;
};

$scope.saveEditor = function () {
    $scope.name = $scope.editName;
    $scope.email = $scope.editEmail;

    $scope.disableEditor();
};

}

1 Answer 1

2

There are multiple issues with your fiddle.

Firstly the scope properties such as studentForm.name.$dirty for ngModelController used in submit is incorrect.

Each of your input should have name properties so that i can be referenced in code under form controller reference.

Secondly for ng-disable it should be button or input not div.

Lastly you can check the form state instead of all input state.

Please check my fiddle: http://jsfiddle.net/cmyworld/dxzeggtp/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.