Hi

I have a form on which I run some validation, if any of the conditions fail I show an alert. For example for the name field

<input type="text" name="name" id="name">
if(trim(cname.value) == '')
   {
      alert('Enter a Name');
      cname.focus();
      return false;
   }

This is called when a user clicks the make booking button:

<input type="button" onclick="return checkForm(); MakeBooking();" value="Book" />

This alert work fine when a user does not enter a name, however when the form entries are valid the MakeBooking() is not getting called.

Do I need to change something so this is called after the validation?

you are returning, so when will it ever get to MakeBooking?

I agree to sillyboy as you wrote return statement so program control will be immediately returned to the checkform() again.

Hi thanks, I didnt realise that is what the control part meant, I have removed that now.
Cheers

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.