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!

Reply via email to