开发者

JQuery Trim as Text Enters field

Hi I have some code..

开发者_高级运维$(document).ready(function() {
    $("#inputPageName").keyup(function () {
          var value = $(this).val();
          $("#inputPageHandle").val(value);
    }).keyup();
});

Basically I need to create a page handle in a hidden field so when the user type in the PageName field it update the PageHandle field however I want to use jQuery.trim() to remove the spaces that the user my put in the PageName field

Any ideas?


You need this?

$(document).ready(function() {
    $("#inputPageName").keyup(function () {
          var value = $.trim($(this).val());
          $(this).val(value);// <-------
          $("#inputPageHandle").val(value);
    }).keyup();
});

EDIT:

maybe you need:

$(document).ready(function() {
    $("#inputPageName").keyup(function () {
          var value = $.trim($(this).val());
          $(this).val(value);// <-------
          $("#inputPageHandle").val(value);
    }).keyup();

    $("#inputPageHandle").keyup(function () {
          var value = $.trim($(this).val());
          $(this).val(value);// <-------
          $("#inputPageName").val(value);
    }).keyup();
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜