function checkForm()
{
        var title= document.myForm.title.value;
        var story= document.myForm.story.value;
        var link= document.myForm.link.value;
        var target= document.myForm.target.value;

        var fbString = '';


        if (title == '')
                fbString = fbString + "You must enter a title\n";
        if (story == '')
                fbString = fbString + "You must enter a story\n";
        if (link != '' && target == '')
                fbString = fbString + "You must enter a target for your
link\n";

        if (fbString != '')
                {
                alert(fbString);
                return false;
                }
        else
                { return true; }
}

...and in your form
<form name="myForm" method="get" action=""
checkForm();">

-mike



Asim Manzur <[EMAIL PROTECTED]>
06/28/2004 03:30 PM
Please respond to cf-talk

        To:     CF-Talk <[EMAIL PROTECTED]>
        cc:
        Subject:        _javascript_ help

Can someone give me a hand on _javascript_ validation?

I have a form  with the following fields

title  <textbox>
story <textarea>
link  <textbox>
target <select box>with the value of "_self" "_blank" and ""

What I want that
"TITLE and STORY should not be empty and if something in the link then
target sould not be empty"

Will appriciate that

Regards,
Asim Manzur
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to