You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Liam Morley <lm...@servprise.com> on 2007/05/07 18:13:09 UTC

how to do custom client-side validation in Tapestry 4.0?

I have two forms on a particular page. Both of them work fine
independently. Now, I want to attach a javascript function to the
onsubmit action of one of the forms to check to see if the OTHER form
has been filled out but not submitted yet. My problem is that onsubmit
seems to be reserved by Tapestry, so I can't do this. I've been trying
to read up on client-side validation on the web, but I'm only finding
Tapestry 4.1 references. Can someone please tell me how I can do custom
form validation in Tapestry 4.0?

As a reference, here's the code for what I *want* to do.

<script type="text/javascript">
    <!--
    function checkFirstForm() {
        var formText = document.getElementById('form1text').value;
        return (formText == "") || confirm("Are you sure you want to
continue without submitting the first form?");
    }
    -->
</script>


<form name="form1">
<input type="text" name="form1text" id="form1text">
<input type="submit">
</form>

<form name="form2" onsubmit="return checkFirstForm();">
...
<input type="submit">
</form>


I'm using a delegate for server-side validation for the second form, so
I need to keep that. I know that I can't do this particular validation
on the server side because then I wouldn't have access to the
"form1text" box when submitting form2. It's not possible to consolidate
these two forms.

Thanks very much for the help!

Liam Morley

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org