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.
Unfortunately, activation email could not send to your email. Please try again.

How to prevent user from entering first whitespace character

Thread ID:

Created:

Updated:

Platform:

Replies:

120163 Sep 7,2015 02:23 AM Sep 10,2015 07:03 AM JavaScript 4
loading
Tags: ejGrid
Bharat Buddhadev
Asked On September 7, 2015 02:23 AM

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 02:35 AM

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 08:06 AM

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.

$("#Grid").ejGrid({  

     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

Regards,

Isuriya R


Bharat Buddhadev
Replied On September 9, 2015 08:01 AM

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 07:03 AM

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.

<script>

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

         if(evt.keyCode == 32){

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

           obj.editFormValidate();

                     }

                 })    

 </script>


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

Sample:  Sample

Regards,

Isuriya R


CONFIRMATION

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.

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.

;