html part:
<input type="text" id="st_1" />
<input type="text" id="st_2" />
<input type="text" id="st_3" />
<button onClick="trimAllTextInput()">Save</button>
JavaScript part:
<script>
String.prototype.trim = function() {
try {
return this.replace(/^\s+|\s+$/g, "");
} catch(e) {
return this;
}
}
function trimAllTextInput(){
var inp = document.getElementsByTagName('input');
for(var i in inp){
//if(inp[i].type == "text" && inp[i].id.substring(0,3)){
if(inp[i].type == "text"){
inp[i].value = inp[i].value.trim();
}
}
}
</script>
Reference :
https://stackoverflow.com/questions/196925/what-is-the-best-way-to-trim-in-javascript
PHP MySQL PDO Database Connection
ReplyDeletePHP create image from text and save
How to get data from XML file in PHP
PHP Server Side Form Validation
SQL Injection Prevention Techniques
Characteristics of a Good Computer Program
Submit a form data without page refresh
Splitting MySQL Results Into Two Columns Using PHP
Dynamically Add/Delete HTML Table Rows