473,320 Members | 1,699 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,320 software developers and data experts.

Mandatory Fields

OK so its been a while since I have had to put some field checking code together, I thought what I had done was fairly simple but nothing ever is, is it!?

This my script code:

Expand|Select|Wrap|Line Numbers
  1. <SCRIPT LANGUAGE="JavaScript">
  2. <!--
  3.     function validate(frm) 
  4.     {
  5.         if (frm.lb_dept.value.length == 0)
  6.         {
  7.             alert("Please enter a Requestors Department.")
  8.             frm.lb_dept.focus()
  9.             return false
  10.         }
  11.  
  12.         if (frm.lb_sub_dept.value.length == 0)
  13.         {
  14.             alert("Please enter a Requestors Sub-Departmen.")
  15.             frm.lb_sub_dept.focus()
  16.             return false
  17.         }
  18.  
  19.         if (frm.lb_type.value.length == 0)
  20.         {
  21.             alert("Please enter a Request Type.")
  22.             frm.lb_type.focus()
  23.             return false
  24.         }
  25.  
  26.         if (frm.lb_priority.value.length == 0)
  27.         {
  28.             alert("Please enter a Request Priority.")
  29.             frm.lb_priority.focus()
  30.             return false
  31.         }
  32.  
  33.         if (frm.target_date.value.length == 0)
  34.         {
  35.             alert("Please enter a Target Date .")
  36.             frm.target_date.focus()
  37.             return false
  38.         }
  39.     }
  40. //-->
  41. </SCRIPT> 
So I check the length of 5 fields and return false if they are 0.

This is the first line of my form:

[HTML]<form id="logcallform" name="logcallform" method="POST" onsubmit="return validate(logcallform)" action="php/xmlhttp/logcall.submit.php">[/HTML]
My validation function never seems to get called!

I am a not 100% sure if I can leave the action tag in the form of if I need to put that in an else tag within the validation code?

Any help is much appreciated.
Nov 19 '07 #1
1 1202
gits
5,390 Expert Mod 4TB
hi ...

welcome to TSDN ...

try:

Expand|Select|Wrap|Line Numbers
  1. <form id="logcallform" name="logcallform" method="POST" onsubmit="return validate(this)" action="php/xmlhttp/logcall.submit.php">
that way we pass the correct reference to the form itself

kind regards
Nov 19 '07 #2

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

Similar topics

1
by: Le Tubs | last post by:
Hi I am wondering if anybody has come accross this problem before, basically I have to validate a xml schema (not the data, this is done at a later stage). The only problem is that there are...
1
by: AR123 | last post by:
Hi I have set up mandatory form fields but it dosne t seem to be working. Would appreciate it if somone could have a look. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> ...
4
by: plumba | last post by:
Let me explain.... I have a form (most of which you guys have helped me with!!). The initial problem I was having is that it was holding the data in the fields after submit, I resolved this by...
1
by: AR123 | last post by:
The mandatory form field that is not working is the TYPE OF ILLUSTRATION. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Proforma</title> <meta...
2
by: bugsbunny12345 | last post by:
i have a form contains 7 fields .. in that if the user enters the value in any one of the field all the remaining 6 fields should be MANDATORY.. if the user didn't enter any value in any field ...
2
by: AR123 | last post by:
Hi I have set up a form. What I want to to is with the fields: Company Postcode Agency Number Policy Number I want these to be mandatory however if someone fills in the company postcode for...
6
by: Dameon99 | last post by:
Ive been looking through a whole tonne of sites to try to find out how I can make my fields mandatory but havnt been able to find something so far which actually tells me whwta I want to know. Ive...
1
by: ajd335 | last post by:
Hi.. there are some radio buttons,which are mandatory in my site. So how can i find whether they are filled by the user or not ..so that i can respond accordingly.(i.e if all mandatory fields are...
7
by: sva0008 | last post by:
Hi , I have a scenario in which i have four input fields in asp with the same name batchlist. I have a button called add batch . The user can add the batch by clicking the add batch button . out...
1
pradeepjain
by: pradeepjain | last post by:
Hii , I have a form which has 20-30 textboxes which are mandatory ! is there a way of validating mandatory fields in easier ways by using a single function or some thing like tht ! bcos i...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.