I have 20 Elements in the form, so I would like to use
rules:{
$all:webix.rules.isNotEmpty
}
But, only 1 is not compulsory to be filled? Is there any shortcut to do the validation? Or I must state the 19 elements for data validation?
I have 20 Elements in the form, so I would like to use
rules:{
$all:webix.rules.isNotEmpty
}
But, only 1 is not compulsory to be filled? Is there any shortcut to do the validation? Or I must state the 19 elements for data validation?
perhaps you did not set name
attribute in elements’ config. to be validated each element must have own name.
Hi @intregal , by referring the snippet below, I means if I want to validate all of the field to ensure it is not empty except Remarks field. Does it means I can’t use
rules:{
$all:webix.rules.isNotEmpty
}
As I may have a lot field which have to validate to ensure it is not empty.
“$all” means “NO exception”. and current validation config works.
if you want selective validation you need to use “$obj” key.
https://docs.webix.com/samples/13_form/04_validation/08_confirmation.html
okay… means I cant use $all. I have to validate the rest of compulsory field one by one.
Thanks.
Still, you can use the $all
rule, but you need apply a custom function for validation:
$all:function(value, fields, name){
if(name !=="remarks") //all fields but one
return webix.rules.isNotEmpty(value);
else //some other rule or just consider it valid
return true;
}
Please, check the following snippet: https://webix.com/snippet/26cd9124
Hi @Helga … Amazing, I didnt realize the rule function allowed me to pass the parameter. May I know what is inside the fields parameter? And wehere can I get the relevant document?
Hello,
Well, it’s a bit undocumented functionality…) We will correct the docs on this topic.
Normally, each validation rule expects a function that will return true
or false
, no matter whether it’s a function for a certain field, or the one enterted via the $all
or $obj
keywords.
The $all
function is called for each form field and takes the following parametes:
.getValues()
returns)Hi webix Team
In username field iam using the space bar, at the time text field is empty, so once we use space bar also it want to show error message
https://webix.com/snippet/b11c8a0e
Thank’s in advance
Deepak
Hello @deepak ,
As a solution, you can call a custom rule which will consider space as error.
Or using value
without spaces via method replace
replace(/ /g,"")
Here is an example: https://webix.com/snippet/d8ad7dd7