I am sorry. I kind of posted the wrong solution.
Here we go!

    <h:commandButton id="submit" styleClass="button" action=""  />

        <script type="text/_javascript_">
        <!--
           function validate(form){
                var requestor = form["HWRForm:requestedby"].value;
                var error;
                if(requestor && requestor.match(/^\s*\w*\s*\w*$/)){
                        form.submit();
                        return true;
                } else{
                    alert('Please enter the Requestors Name');
                    return false;
                }
            }
         -->

Enjoy,
-M
Meghana <[EMAIL PROTECTED]> wrote:
Thanks Ray. That helped. I fixed it by always returning false as:


Thanks,
-M
Julian Ray <[EMAIL PROTECTED]> wrote:
This link might help
 
 
 


From: Meghana [mailto:[EMAIL PROTECTED]
Sent: Monday, June 19, 2006 3:59 PM
To: [email protected]
Subject: Navigation problem with _javascript_

Hi,
  I am using a _javascript_ function to check a required field and to check if the user has entered whitespace to bypass validation.

Here is the code:
<h:commandButton id="submit" styleClass="button"
            action="" />

function validate(form){
                var requestor = form["HWRForm:requestedby"].value;
                var error;
                if(requestor && requestor.match(/^\w+$/)){
                      form.submit();
                } else{
                      alert('Please enter the Requestors Name');
                }
}

When the user doesn't enter any thing for the field 'requestedby', the alert is shown and the control stays in the same page. But when the user enters a whitespace for the aforementioned field and clicks on the button the alert is shown and is taken to another the page as if it were a success. Can anyone please help me out?

Thanks a lot,
-M

Yahoo! Sports Fantasy Football ’06 - Go with the leader. Start your league today!


Ring'em or ping'em. Make PC-to-phone calls as low as 1¢/min with Yahoo! Messenger with Voice.


Yahoo! Groups gets better. Check out the new email design. Plus there’s much more to come.

Reply via email to