Jump to content

how to get a text field value into javascript variable


bindiya

Recommended Posts

I have a html form.

i have the fields like username,password,firstname,address.

 

I have placed the username inside another form because onblur event this textfiels value should b recieved by the js.

But js is not recieving the value.Gives the error'document.usercheck.username  is null or nota an object.

 

My code is

<script language="javascript">

function submit_check(){

var name=document.usercheck.username.value;

location.href="user_availability.php?login="+name;

document.forms['usercheck'].submit();

  }

 

html-------------

<form name='registration' action='' method='post' onsubmit="return verify();">

 

 

<table width="599" align='center'>

 

<tr><td  colspan='5'></td></tr>

<tr><td width="33"></td>

<td width="187"><!--UserName<suponblur='submit(this.value);'>onblur='submit_check(this.value);'-->

User Name <font color="#CC0000">*</font></sup>

</td>

<td width="22">:</td>

<td width="148">

<div>

              <form name='usercheck' method="post" action=''> <input name="username" type="text" id="username"  value="" maxlength="15"  onblur="submit_check();" /></td><td width="185"></form><</td>

</tr>

<tr><td width="33"></td>

<td width="187">Password<sup><font color="#CC0000">*</font></sup></td>

<td width="22">:</td>

<td width="148"><input name="password" type='text' id='password' /></td><td></td></tr>

 

<tr><td width="33"></td>

<td width="187">Re Password<sup><font color="#CC0000">*</font></sup></td>

<td width="22">:</td>

<td width="148"><input name="repassword" type='text'  id='repassword'/></td><td></td></tr>

</table></form>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.