If the validate function isn't doing much except working on specific objects
(document.tester.mytext.value), then there isn't much point in moving it to
its own function imo.
Example:
Mungbeans wrote:
>
> Thank you, Karl. This code now works well:
>
> $(document).ready(function() {
> $("#sendmail").click( function() {
> validate();
> return false;
> });
> });
>
> function validate() {
> if ( document.tester.mytext.value == "" ) {
> alert ('Your have not provided a mytext');
> } else {
> document.op.value = "Send";
> document.tester.submit();
> }
> }
>
> Now the form works nicely with or without _javascript_.
>
--
To be more jQuery like (and cut down on code), it may be better to do this:
$(document).ready(function() {
$("#sendmail").click(validate);
});
function validate() {
$tester = $("#tester");
if ( $tester.find("#mytext").val() == "" ) {
alert ('Your have not provided a mytext');
return false;
} else {
$("#op").val("Send");
return true;
}
}
If $("#op").val("Send") does not work, you can always do $("#op")[0].value = "Send"
This is assuming you have <input type="submit" id="sendmail" value="send email"> within the form (rather than <button>).
_______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/