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

How to prevent user from entering first whitespace character

jquery validation  with grid

1) I do not want to allow user to enter first while charcater in grid textbox

4 Replies

BB Bharat Buddhadev September 7, 2015 06:35 AM UTC

last post statement is incorrect 
 I do not want to allow user to enter first whitespace character in grid textbox

IR Isuriya Rajan Syncfusion Team September 8, 2015 12:06 PM UTC

Hi Bharat,

Thanks for contacting the Syncfusion support.

Using the custom validation in jQuery, we can set the customized validation condition for Textbox. Please refer to the below code example to know how can we add the custom validation for Textbox. Using the addMethod, we can add custom validation in jQuery validator.


     columns: [

                            { field: "CustomerID", headerText: 'Customer ID', width: 90, validationRules: { customRegex: " "} }, // Custom validation                         



$.validator.addMethod("customRegex", function (value, element, params) {

     if (element.value.indexOf(params) == 0)

         return false;

     return true;

}, "Contains the white sapce");

Please share the following details,  


1.  Do you want to check your validation condition before save action? 

2.  Want to display the validation message? 

We have created a sample in jsplayground: Sample


Isuriya R

BB Bharat Buddhadev September 9, 2015 12:01 PM UTC

Thanks for reply 
I want to apply on keypress event instead of save action or click on enter button 

so when user put input validation will firevalidation and check vaildation

here I want validation on keypress before save or enter action
Waiting for your quick reply

IR Isuriya Rajan Syncfusion Team September 10, 2015 11:03 AM UTC

Hi Bharat,

Your requirement is achieved by using keyup event in Grid. We have used editFormValidate method to check validation condition and display the validation message.


       $(document).on("keyup","#GridEditForm input" ,function(evt){

         if(evt.keyCode == 32){

           var obj=$("#Grid").ejGrid("instance");





We have also created a sample using keyup event in jsPlayground, 

Sample:  Sample


Isuriya R

Live Chat Icon For mobile
Up arrow icon