Trim text boxes and texaria on form submission for submit

I cut everything textboxes and textareas on submit

. It doesn't work for all browsing pages.

I took it simple html inputs + kendo DropDownList + kendo AutoComplete

in its form.

Below is my submit method which doesn't work when there is one in my form Kendo UI control

.

$('input[type="submit"]').click(function () {
   $('input[type=text], textarea').each(function () {
     if($(this).val()!=''){
       $(this).val($.trim($(this).val())); //Exception in chrome: paused on exception typeerror. Msg: undefined in not function.
     }
   });
});

      

I do not know what happened. I found this problem specific to chrome browser

.

+3


source to share


3 answers


I do not know what happened. So I have updated the function as shown below:

$('input[type="submit"]').click(function () {
   $('#textbox1,#textbox2,#textarea1').each(function () {
     if($(this).val()!=''){
       $(this).val($.trim($(this).val()));
     }
   });
});

      



I wrote the IDs of all the textboxes and the textbox that I need to trim inside each one. And it works great. But still I have a question why the generalization function is not working.

0


source


Is it just kendo control? Their DropDownList for example displays this (from the demo)

<input id="color" value="1" data-role="dropdownlist" style="display: none;">

      



Note, there is no attribute type=text

, so your selector probably doesn't include this.

+2


source


There seems to be no problem in your normal HTML and JS code. Check other code in your project, Weather is blocking it in your code.

Maybe check Kendo UI Syntax / Format / Attributes for Html controls. This could be a problem.

Take a look at my violin fiddle . I tested it to work.

There is an no

exception Like -//Exception in chrome: paused on exception typeerror

+2


source







All Articles