Question

Asked on 2011-09-02 at 00:16:05ID: 27288373

Confirm Box cancel button not working

by: Keerthana460

Rating8.2Very Good

Hi. I have a registration form in which i have to validate and show a confirm box in the same page.. i m doing both as two diff function calls and i m calling a function inside another function because a form cannot have two functions on submit.. please check my code and let me know the mistakes

/**********code for validation*******/

 <script type="text/javascript">   
function validateForm()
{

    if(document.form1.Userid.value=="")
    {
      alert("User Name should not be left blank");
      document.form1.Userid.focus();
      return false;
    }
   if(document.form1.Usertype.value=="")
    {
      alert("Usertype should not be left blank");
      document.form1.Usertype.focus();
      return false;
    }
     if(document.form1.Username.value=="")
    {
      alert("Username should not be left blank");
      document.form1.Username.focus();
      return false;
    }

     if(document.form1.Email.value=="")
    {
      alert("email should not be left blank");
      document.form1.Email.focus();
      return false;
    }
     if(document.form1.mobile.value=="")
    {
      alert("mobile should not  be left blank");
      document.form1.mobile.focus();
      return false;
    }
  
   var x=document.forms["form1"]["Email"].value
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
  {
 
  alert("Not a valid e-mail address");
  return false;
  }
  
  
  ConfirmAmount();
   return true;
  
}

 </script>  
/**********End of validation*********/


/****Second function for confirm box******/
<script type="text/javascript"> 
function ConfirmAmount()
{
var amount = document.getElementById("Userid").value;
if(confirm("Confirm . Click OK if **" + amount + " is the correct Data."))


if (amount== true)
{
 document.form1.submit()
}
else
{
location.href="CreateUser.jsp";
}
}
  
 </script>

/************************************/

Step3:
/************Form**********/

       			 <form name="form1" method=post action="nuser.jsp" onsubmit="return validateForm()";>
 				   <label for="nuserid">Userid</label>
                   <input type="text" name="Userid" id="Userid" size="30"/><br/>
				   <div style="float:left; margin-5:px;"> <label for="nuserid">UserType</label><select name="Usertype" size="1">
					<option value="1" >VMR admin</option>
					<option value="2">MerchantCard</option>
					<option value="3">VMR Cust Support</option>
					<option value="4">CardHolder</option>
        			</select><br /></div>
                    <br/>
                     <label for="nuserid">UserName</label>
                   <input type="text" name="Username" id="Username" size="30"/><br/>
                   <label for="nuserid">Email</label>
                   <input type="text" name="Email" id="Email" size="30"/><br/>
                   <label for="nuserid">Mobile</label>
    	           <input type="text" name="mobile" id="mobile" size="20" maxlength="10" id="txtChar" onkeypress="return isNumberKey(event)" type="text" name="txtChar"/><br/>
	           
        		   <label for="nuserid">EffectiveDate</label><input type="text" name="start_date" value=""><div style="float:left; margin-5:px;">
           			<a href="javascript:showCalendar('',document.forms[0].start_date,null,'','',0,30,1)"><img src="images/Calendar_scheduleHS.png" width="16" height="16" alt="" border="0" /></a></div>

           
        <br/>
             <label for="nuserid">InactiveDate</label><input type="text" name="end_date" value=""/><div style="float:left; margin-5:px;"><a
  href="javascript:showCalendar('', document.forms[0].end_date, document.forms[0].start_date, '','', 0,30, 1)"><img src="images/Calendar_scheduleHS.png" width="16" height="16" alt="" border="0" /></a></div>

             <br/> 

              <div style="padding-left:300px"><input type="submit" value="ok"/></div>
            <input type="button" value="Back" onclick="goBack()"/>
                   </div> 
                  </form>  
                   <br/>
             
 </center>
/******End of Form*********/
                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:

Select allOpen in new window

Related Solutions

Solution

Sign up now to view this solution! It's quick, easy, and secure to subscribe. We will return you to this solution, unlocked, when you’re done.

About this Solution

View This Solution - Start Your 30 Day Free Trial
Zone
general
Tags
Validations confirm box in same page
Participating Experts
2
Solution Grade
A

Replies

 by: Keerthana

Posted on 2011-09-02 at 00:18:47ID: 36471947

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: itkamaraj

Posted on 2011-09-02 at 08:57:50ID: 36474237

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: Keerthana

Posted on 2011-09-02 at 21:43:22ID: 36476987

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: itkamaraj

Posted on 2011-09-02 at 21:55:01ID: 36477004

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: Keerthana

Posted on 2011-09-02 at 22:00:19ID: 36477011

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: Keerthana

Posted on 2011-09-02 at 22:11:33ID: 36477025

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: mplungjan

Posted on 2011-09-07 at 09:16:41ID: 36496976

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

 by: Keerthana

Posted on 2011-09-07 at 21:47:12ID: 36500688

All comments and solutions are available to Premium Service Members only. Sign up to view the solution to this question. Already a member? Log in to view this solution.

Log In

Forgot your password?Sign up

Top Experts

  1. mplungjan

    1,840

    0 points yesterday

    Profile

BrowseAre you an Expert?