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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to prevent user from entering first whitespace character

Thread ID:





120163 Sep 7,2015 06:23 AM UTC Sep 10,2015 11:03 AM UTC JavaScript 4
Tags: ejGrid
Bharat Buddhadev
Asked On September 7, 2015 06:23 AM UTC

jquery validation  with grid

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

Bharat Buddhadev
Replied On 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

Isuriya Rajan [Syncfusion]
Replied On 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

Bharat Buddhadev
Replied On 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

Isuriya Rajan [Syncfusion]
Replied On 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


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon