开发者

JQuery Trim as Text Enters field

开发者 https://www.devze.com 2023-04-11 15:12 出处:网络
Hi I have some code.. 开发者_高级运维$(document).ready(function() { $(\"#inputPageName\").keyup(function () {

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

精彩评论

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