Search code examples
javascriptblockconfirmation

why run both of confirmation of if()else in javascript?whats solution?


I write code to check a form and if user enter all of information run confirm that show " are you sure to submit?".i use this for two form in onclick attribute. My code is same this:

Var strurl=window.location.search();
 If(strurl.search("click=edit")>0)
  {
 If(document.forms["frm"]["fname"].value="")
 { alert("please enter all information required");
  Return false;
}

Return Confirm("are you sure to submit?");

}
Else
{

If(document.forms["frm"]["tel_num"].value="")
  { alert("please enter all information required");
 Return false;
  }

Return Confirm("are you sure to submit?");



}

This code is for two form that one of these form show in one condition and dont show both form by php programming.

But my problem is run both confirm in both form and i couldnt block one of them in another form.

I know that can seperate to two page but for a reason i should use these codes in one page.

What should i do to solve this?


Solution

  • I found the problem.:-) I call twice this function.I found that between 1000 line of codes after 5 hours search.