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 for inserting data after maximum lenth

Thread ID:

Created:

Updated:

Platform:

Replies:

119926 Aug 14,2015 09:33 AM Aug 17,2015 12:00 PM JavaScript 1
loading
Tags: ejGrid
Bharat Buddhadev
Asked On August 14, 2015 09:33 AM

Using jquery and gridview

I want to prevent user from entering data more that 50 character

so while inserting content user keyboard should not allow to insert data means key press event should not work

so after maximum no of character entered by user. user should not allowed to insert data.

I do not want to fire event on click on save


2) I wan to fire required field validation on tab button.

  for example when I click on first text box after insert value, when click on tab button required field should fire.
In current scenario when I insert data and after click on save button on tool bar it fires required field validation 
but i want to fire required field validation on tab button.











Isuriya Rajan [Syncfusion]
Replied On August 17, 2015 12:00 PM

Hi Bharat,

For easy communication purposes, we have presented the response in a table format as below:

                                    Query

                                   Response

1)I want to prevent user from entering data more that 50 character

so while inserting content user keyboard should not allow to insert data means key press event should not work

so after maximum no of character entered by user. user should not allowed to insert data.

I do not want to fire event on click on save

You can achieve your requirement by using this actionComplete event.It will trigger every action completed in the Grid.

In code given below, we have bound  keypress event for all input fields. But you can also bind this event to specific columns.

function actionComplete(args) {

if (args.requestType == "add" || args.requestType == "beginedit")             

            $("#"+this._id+"EditForm").find('.e-ejinputtext').keypress(function (e) {

                    if (this.value.length > 3) {

                        // check the condition for keypressed and disable the key press event

                        return false

                    }

                });

        }

2) I wan to fire required field validation on tab button.

  for example when I click on first text box after insert value, when click on tab button required field should fire.

In current scenario when I insert data and after click on save button on tool bar it fires required field validation 

but i want to fire required field validation on tab button

We can set validation for a  grid as per our requirement.Based on the requirement we have to set  validationRules .

By default behavior of the jquery validator, it can’t fire the validation error on tab key press validation. So we have to set manually validation on onfoucout event. By using this event we can enable the validation for tab key press.

Here’s the code that demonstrates  how we can enable the validation condition for tab key press.

$(function () {

           $.validator.setDefaults({ onfocusout: function (element) { $(element).valid() } });

       })      

</script>

Please refer this documentation link for how we can use validation for grid columns.

Online Sample Link: Validation

We have created a downloadable sample for this:

Sample Link: http://www.syncfusion.com/downloads/support/directtrac/general/New_Compressed_(zipped)_Folder_(2)1940114524.zip

Online sample: Sample

Please try the above sample and let us know if it helps. Please let us know if we have missed anything and we will gladly assist.

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.

;