We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Required validation in query builder

Hello,


How can we handle validation for blank spaces in the field


example:querybuilder.png

If we enter three spaces in the input field, this does not show me field required.


Do you have any idea how can we achieve?


Thank you


1 Reply 1 reply marked as answer

YA YuvanShankar Arunagiri Syncfusion Team December 19, 2022 09:15 AM UTC

Sorry for the delay, Saikiran,


In our validateFields method, check whether the value field contains a null or empty string value for validation. But in your case, you typed more than 1 space, so only it is not validated properly. To resolve this issue, please refer to the code snippet and sample link.


Using the beforeChange event, we can handle the case where more than 1 empty string has one empty string.


let qryBldrObjQueryBuilder = new QueryBuilder({

    dataSource: employeeData,

    columns: columnData,

    allowValidation: true,

    beforeChange: onChange

});

qryBldrObj.appendTo('#querybuilder');

 

……………………………………………………….

 

function onChange(argsany) {

    if (args.type === "value" && !/[a-zA-Z]/.test(args.value)) {

        args.value = "";

    }

}

 


Sample link: https://stackblitz.com/edit/rmaghu?file=index.ts


Please get back to us if you need any further assistance on this. 


Marked as answer
Loader.
Up arrow icon