473,406 Members | 2,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

call function

hi evryone.....i would like to ask your favour regarding on my php code.....this is my code....

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <title>
  4. </title>
  5. <script type="text/javascript">
  6. function validation()
  7. {
  8.     var valid=true;
  9.     if(document.form2.icnumber.value=="")
  10.     {
  11.         alert(" Please fill in the ' Identification Card Number ' textbox. ");
  12.         document.form2.icnumber.focus();
  13.         valid=false;
  14.     }
  15.  
  16.     if(document.form2.name.value=="")
  17.     {
  18.         alert(" Please fill in the ' Name ' textbox. ");
  19.         document.form2.name.focus();
  20.         valid=false;
  21.     }
  22.  
  23.     if(document.form2.position.value=="")
  24.     {
  25.         alert(" Please fill in the ' Position ' textbox. ");
  26.         document.form2.position.focus();
  27.         valid=false;
  28.     }
  29.  
  30.     if(document.form2.department.value=="")
  31.     {
  32.         alert(" Please fill in the ' Department ' textbox. ");
  33.         document.form2.department.focus();
  34.         valid=false;
  35.     }
  36.  
  37.     /*if(document.form2.email.value=="")
  38.     {
  39.         alert(" Please fill in the ' Email ' textbox. ");
  40.         document.form2.email.focus();
  41.         valid=false;
  42.     }*/
  43.  
  44.     if(document.form2.phoneno.value=="")
  45.     {
  46.         alert(" Please fill in the ' Phone Number ' box. ");
  47.         document.form2.phoneno.focus();
  48.         valid=false;
  49.     }
  50.  
  51.      if(document.form2.username.value=="")
  52.     {
  53.         alert(" Please fill in the ' User Name ' textbox. ");
  54.         document.form2.username.focus();
  55.         valid=false;
  56.     }
  57.  
  58.     if(document.form2.password.value=="")
  59.     {
  60.         alert(" Please fill in the ' Password ' box. ");
  61.         document.form2.password.focus();
  62.         valid=false;
  63.     }
  64.     return valid;
  65. }
  66.  
  67. function echeck(str) {
  68.  
  69.         var at="@"
  70.         var dot="."
  71.         var lat=str.indexOf(at)
  72.         var lstr=str.length
  73.         var ldot=str.indexOf(dot)
  74.         if (str.indexOf(at)==-1){
  75.            alert("Invalid E-mail ID")
  76.            return false
  77.         }
  78.  
  79.         if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
  80.            alert("Invalid E-mail ID")
  81.            return false
  82.         }
  83.  
  84.         if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
  85.             alert("Invalid E-mail ID")
  86.             return false
  87.         }
  88.  
  89.          if (str.indexOf(at,(lat+1))!=-1){
  90.             alert("Invalid E-mail ID")
  91.             return false
  92.          }
  93.  
  94.          if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
  95.             alert("Invalid E-mail ID")
  96.             return false
  97.          }
  98.  
  99.          if (str.indexOf(dot,(lat+2))==-1){
  100.             alert("Invalid E-mail ID")
  101.             return false
  102.          }
  103.  
  104.          if (str.indexOf(" ")!=-1){
  105.             alert("Invalid E-mail ID")
  106.             return false
  107.          }
  108.  
  109.           return true                    
  110.     }
  111.  
  112. function ValidateForm()
  113. {
  114.     var emailID=document.form2.email
  115.  
  116.     if ((emailID.value==null)||(emailID.value==""))
  117.     {
  118.         alert("Please Enter your Email ID")
  119.         emailID.focus()
  120.         return false
  121.     }
  122.  
  123.     if (echeck(emailID.value)==false){
  124.         emailID.value=""
  125.         emailID.focus()
  126.         return false
  127.     }
  128.     return true
  129. }
  130.  
  131. function valForm()
  132. {
  133.  
  134.     validateForm();
  135.     validation();
  136.  
  137. }
  138.  
  139. </script></head>
  140. <body>
  141. <form name="form2" method="post" action="register0.php" onSubmit="return valForm();">
  142.  
  143. <table border=3>
  144. <tbody>
  145. <tr>
  146. <td style="text-align: center;">
  147. <p><strong>Registration Form</strong></p>
  148. <table border="0" cellspacing="1" cellpadding="3">
  149. <tbody>
  150.  
  151. <tr align="left" bgcolor="#FFFFFF">
  152. <td><span style="font-family: Arial; font-size: small;">Identification Card Number</span></td>
  153. <td><span style="font-family: Arial; font-size: small;"> : </span></td>
  154. <td><span style="font-family: Arial; font-size: small;"><input type="text" name="icnumber"></span></td>
  155. </tr>
  156.  
  157. <tr align="left" bgcolor="#FFFFFF">
  158. <td><span style="font-family: Arial; font-size: small;">Name</span></td>
  159. <td><span style="font-family: Arial; font-size: small;"> : </span></td>
  160. <td><span style="font-family: Arial; font-size: small;"><input type="text" name="name"></span></td>
  161. </tr>
  162.  
  163. <tr align="left" bgcolor="#FFFFFF">
  164. <td><span style="font-family: Arial; font-size: small;">Position</span></td>
  165. <td><span style="font-family: Arial; font-size: small;"> : </span></td>
  166. <td><span style="font-family: Arial; font-size: small;"><input type="text" name="position"></span></td>
  167. </tr>
  168.  
  169. <tr align="left" bgcolor="#FFFFFF">
  170. <td><span style="font-family: Arial; font-size: small;">Department</span></td>
  171. <td><span style="font-family: Arial; font-size: small;"> : </span></td>
  172. <td><span style="font-family: Arial; font-size: small;"><input type="text" name="department"></span></td>
  173. </tr>
  174.  
  175. <tr align="left" bgcolor="#FFFFFF">
  176. <td><span style="font-family: Arial; font-size: small;">Email</span></td>
  177. <td><span style="font-family: Arial; font-size: small;"> : </span></td>
  178. <td><span style="font-family: Arial; font-size: small;"><input type="text" name="email"></span></td>
  179. </tr>
  180.  
  181. <tr align="left" bgcolor="#FFFFFF">
  182. <td><span style="font-family: Arial; font-size: small;">Phone Number</span></td>
  183. <td><span style="font-family: Arial; font-size: small;"> : </span></td>
  184. <td><span style="font-family: Arial; font-size: small;"><input type="text" name="phoneno"></span></td>
  185. </tr>
  186.  
  187. <tr align="left" bgcolor="#FFFFFF">
  188. <td><span style="font-family: Arial; font-size: small;">User Name</span></td>
  189. <td><span style="font-family: Arial; font-size: small;"> : </span></td>
  190. <td><span style="font-family: Arial; font-size: small;"><input type="text" name="username"></span></td>
  191. </tr>
  192.  
  193. <tr align="left" bgcolor="#FFFFFF">
  194. <td><span style="font-family: Arial; font-size: small;">Password</span></td>
  195. <td><span style="font-family: Arial; font-size: small;"> : </span></td>
  196. <td><span style="font-family: Arial; font-size: small;"><input type="password" name="password"></span></td>
  197. </tr>
  198.  
  199. <tr align="left" bgcolor="#FFFFFF">
  200. <td colspan=3 align=center><span style="font-family: Arial; font-size: small;"><input type="submit" name="submit" value="Send Form"><input type="reset" name="reset" value="Empty Form"></span></td>
  201. </tr>
  202.  
  203. </tbody>
  204. </table>
  205. </td>
  206. </tr>
  207. </tbody>
  208. </table>
  209. </form>
  210. </body>
  211. </html>

I would like to use function valForm when clicking on submit button....unfortunately, the validation function and the validate form is not working.....somebody plz help me.....
Feb 2 '12 #1
3 1263
Rabbit
12,516 Expert Mod 8TB
What do you mean by not working.
Feb 2 '12 #2
rabbit:

the 1st case is : (in function validation)
for example,i didn't enter any information in one of the text box.when i click submit, it should display an alert box saying that, "Please fill in 'Name' textbox" for example...but, instead of that, it just go to new window and display "Data have been save" or "Record existed". Thus, there will be an empty space in a database.


the 2nd case is: (in function validateForm)
it should display an alert box when we entered wrong email....it act as an email validation. as we see, in function validation, i had already put the email validation as a comment so that the system will not be malfunction. before this, i had tried the function validateForm in another page, and it is working.so i would like to combine it with the other textbox validation that is function validation.

3rd cases : (function valForm)
this function should be able to validate all textbox in this register.php page(the code for register.php page is as above code that i had post in the question)which including the email validation and name,department etc.unluckly it is not working as i expected. so, i would like to ask your opinion on what should i do so that both function is working.
Feb 2 '12 #3
Rabbit
12,516 Expert Mod 8TB
1) Your onsubmit called function never returns true or false depending on the return values of the functions that it calls. That's why it always submits. Also, you never see the alerts because ValidateForm fails to run correctly.

2) ValidateForm and echeck is not valid javascript. I suspect in the other page you were using vbscript. They are not the same. You need to port those functions to javascript.

3) This is directly related to the previous issues.
Feb 2 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Lucy Randles | last post by:
I've written a VBA function that I then need to call in a form. Previously to do this I have written the call procedure in the same module as the function - i.e. Function callfunctionname() Call...
2
by: PawelR | last post by:
Hello Group, In my application I have few class, and I want call function with "master class". This is as master form (startClass) and option window (ClassA). My question is how call function...
4
by: Dave | last post by:
I have a program that I've written a class for. I need to call the function in the program from the class. When I try to call the function I receive the error, the name xxx does not exist in the...
2
by: moondaddy | last post by:
I'm using vb.net and have an aspx page where I want to call a function in the code behind to do something on the backend and I want to call this function from a jscript function in the aspx page. ...
7
by: Tiraman | last post by:
Hi , I have 3 files , middle.aspx file include the header.aspx and footer.aspx files . in each of the include files there is a function and from some reason the call to the Footer() function...
12
by: leaf | last post by:
Hi, How to call function at runtime, based on a struct that contains the information for the function call: struct func_to_call { int function_id; // function id to call unsigned int nparams;...
5
by: yaru22 | last post by:
Hi. I'm wondering if there is a way to call function that a variable refers to. I was writing a script to load xml file. And what I've written so far looks like this: var xmlDoc; ...
1
by: Khai Doan | last post by:
I have function A, which need to call function B with the exact same argument list. What is the correct way to do this? I had function A: function A { B(arguments); } but it does not...
9
by: Andrew Poulos | last post by:
Say I have this: var foo = function(x, y) { return x + y; }; var bar = function(fname, param1, param2) { /* * how do I call the function "foo" * and pass parameters to it?
1
by: intermanch | last post by:
how call function php($varible) into javascript withod ajax: <!-- this code only call funnctions php but how call function php intermanch@gmail.com www.intermanch.blogfa.com
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.