2017-01-27 4 views

Antwort

1

function myFunction() { 
 
    var x = document.getElementById("fname"); 
 
    if(x.value.length!=0) 
 
    {  
 
    x.value=x.value+" "; 
 
    } 
 
    }
<html> 
 
<body> 
 

 
Enter your name: <input type="text" id="fname" onkeypress="myFunction()"> 
 

 
<p>When you press key into the input field, a function is triggered add space after one char .</p> 
 
<p>If you give space in text box,its two time display, but you can overcome it</p> 
 

 
</body> 
 
</html>