User123
User123

Reputation: 289

How to validate xeditable inputbox

I am using xeditable to have inline editable functionality, but now I am stuck trying to validate my input.

Here is an example using jsFiddle

I tried the below code with no success.

validate: function(value) {
  if($.trim(value) == '') 
    return 'This field is required';
}

Upvotes: 3

Views: 1078

Answers (1)

faressoft
faressoft

Reputation: 19651

You can define a validation function like this:

$scope.validateRequired = function(value) {
  if(!value)
    return "Required field";
};

Then use it with the event onbeforesave

onbeforesave="validateRequired($data)"

Please check:

http://jsfiddle.net/NfPcH/11642/

Upvotes: 2

Related Questions