Form submission problem

My code for xx.jsp will be like this

function Save()

{

if (cond1)

{

do actions;

}

else

{

this.disable=true;{I want the form to be in the same state}

}

}

<formname="xx" action="xx.jsp" method="post">

<input type="submit" name="save" value="Save" onclick=Save();>

</from>

But it is not happening. Other codes in the Save function are being executed but form submit is taking place even though I disable it? I need the button to be of type submit only. How do I do that?

[587 byte] By [harinibiligiria] at [2007-11-26 15:28:43]
# 1

You want the form to not post if you go into the else block? If so try something like this:

function Save()

{

if (cond1)

{

do actions;

return true;

}

else

{

this.disable=true;{I want the form to be in the same state}

return false;

}

}

<form name="xx" action="xx.jsp" method="post">

<input type="submit" name="save" value="Save" onclick=return Save();>

</from>

Also, make sure you have a space in the middle of formname.

kimseya at 2007-7-8 21:44:54 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
You probably want to use the onSubmit event instead of the onClick. Here is an example of form validation using JavaScript: http://www.webreference.com/js/tips/000124.html
tolmanka at 2007-7-8 21:44:54 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...