当前位置: 代码迷 >> Web前端 >> 一个很棒的相仿 Facebook 风格的 TextboxList
  详细解决方案

一个很棒的相仿 Facebook 风格的 TextboxList

热度:786   发布时间:2012-10-08 19:54:56.0
一个很棒的类似 Facebook 风格的 TextboxList
TypeHere.keyup(function (e) {
     switch (e.keyCode) {
         case 188: // ','
            var myInputLength = TypeHere.val().length;
            var myInputText = TypeHere.val().substring(0, myInputLength - 1); // remove ','
            TypeHere.width(myInputLength * 6 + 15);
            //Check for email validation. //You can apply webservices for any type of validation.
            var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
            if (myInputText.length == 0) {
                TypeHere.val('');
                return false;
            }
            if(!emailReg.test(myInputText)) {
              alert('Email Is Invalid');
              TypeHere.val('');
              return false;
            }
            //Create the list item on fly and apply the css
            CreateLi(myInputText)
            //Save into Textbox or HiddenField
            var strValue = txtValues.val() + myInputText + ';';
            txtValues.val(strValue);
            //Push the textbox to the right
            TypeHere.width(myInputLength * 6 + 15);
            //Make the input width to default and set as blank
            liTypeHere.css('left', TypeHere.position().left + TypeHere.width() + 10);
            TypeHere.val('');
            TypeHere.width(10);
            break;
       }
});
  相关解决方案