Jump to content

how to get a text field value into javascript variable


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>

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.