English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

How to use the trim() method in jQuery to remove spaces before and after

As shown below:

function bt_submit(){
 var $title = $.trim($("#title").val());
 if($title=='') {
  ShowMessage("Operator Name cannot be empty","#ff0000");
  return;
 }
 document.all.form1.submit(); 
 }

The following HTML code is as follows:

<tr>
  <td width="18%" align="right">Operator Name:</td>
  <td colspan="3><s:textfield id="title" key="operatorbean.title" size="88" value="%{#request.operatorbean.title}" /> </td> 
  </tr>

This article uses the trim() method in jQuery to remove leading and trailing spaces, which is the entire content shared by the editor. I hope it can provide a reference for everyone and I also hope everyone will support the Yell Tutorial.

You may also like