Reputation: 773
I'm using the schema-based form generator component for Vue.js (vue-form-generator)
Does anyone knows how to avoid dynamically empty spaces in the input field by using the trim()
function?
Here is an example of the code.
Upvotes: 0
Views: 450
Reputation: 1202
Override validator
method by this:
validator: function(value, field, model) {
if (value) {
// if user input anything, then trim it and assign it to the model and validator value also.
// this could be devastating as the user will fill difficulties in typing space
// because as long as user type a space to write a separate word, the validator will remove this, test properly
value = model.name = value.trim();
return VueFormGenerator.validators.string(value, field, model)
} else {
return ["This field is required"];
}
}
Upvotes: 1