I'm getting this.form undefined error message when I submit it. Do I miss anything?


function signup_scramble(uid)

    return false;

<form action="do_signup" method="post" onsubmit="return signup_scramble(this.form.text_username)">

Username : <input type="text" name="text_username" value="" /><br />
Password : <input type="password" name="text_password" value="" /><br />
<input type="submit" name="submit_button" value="Signup" />


Recommended Answers

All 3 Replies

Member Avatar

Change it to the following (the code is not tested)

function signup_scramble(element)
        return false;
<form action="do_signup" method="post" onsubmit="return signup_scramble(document.getElementById('text_username'))">
Username : <input type="text" id="text_username" value="" /><br />
Password : <input type="password" id="text_password" value="" /><br />
<input type="submit" id="submit_button" value="Signup" />

You can use getElementByName, howerver this will return an array as the name attribute does not need to be unique. I would suggest using the id attribute unless you really need to use name.

You could also try this

<script type="text/javscript">
function signup(){
    var username = document.getElementById("text_username").value;
    var password = document.getElementById("text_password").value;
    alert(username + " " + password);
    return false;

<form action="do_signup" method="post" onsubmit="signup()">
Username : <input type="text" id="text_username" /><br />
Password : <input type="password" id="text_password" /><br />
<input type="submit" name="submit_button" value="Signup" />


Or if your form and inputs had a name:

<script type="text/javascript">
function greeting(){
    alert("Welcome " + document.forms["frm1"]["fname"].value + "!")

What is your name?<br />
<form name="frm1" action="submit.htm" onsubmit="greeting()">
<input type="text" name="fname" />
<input type="submit" value="Submit" />

Hope this helps

Thanks guys. You gave me hint.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.