# how to write in web page using Javascript ?



## abudahim (Jul 2, 2005)

i have put some JS code to validate input fields . now i want to inform the user when some input is wrong -like empty user name field - i want to put some code that write some description besides the input field. how i can do this ?
(I dont want alert messages or message boxes)
thanks


----------



## cpscdave (Feb 25, 2004)

put in a blank element where you want your text to go like

```
<div id="txt"></div>
```
then in your javascript have


```
document.getElementById('txt').innerHTML="Your text goes here"
```


----------



## abudahim (Jul 2, 2005)

thank you very much


----------



## krishpitt (Apr 6, 2007)

Better u try this code and write this code in the "SCRIPT" field with some user and password as u like can be set and along with alert message ......... 




function Login(){
var done=0;
var username=document.login.username.value;
username=username.toLowerCase();
var password=document.login.password.value;
password=password.toLowerCase();
if (username=="member1" && password=="password1") { window.location="page.html"; done=1; }
if (username=="member2" && password=="password2") { window.location="page.html"; done=1; }
if (username=="member3" && password=="password3") { window.location="page.html"; done=1; }
if (done==0) { alert("Invalid login!"); }
}


----------

