473,545 Members | 2,639 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Mandatory Fields

1 New Member
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="logcallfo rm" method="POST" onsubmit="retur n validate(logcal lform)" 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 1211
gits
5,390 Recognized Expert Moderator Expert
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
4701
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 Mandatory fields, and Optional fields. Thus I don't think a DTD can be used (as a valid xml file can just have the mandatory fields). I have a...
1
1541
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> <head> <title>Proforma</title> <meta http-equiv=Content-Type content="text/html; charset=windows-1252">
4
2104
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 putting the whole form in a set of <div> tags and the form now collapses after they click submit. Perfect!! But, have set some mandatory fields...
1
3364
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 http-equiv=Content-Type content="text/html; charset=windows-1252">
2
1214
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 it should not lead to any problem... pls suggest me!!!!!
2
1682
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 example the other two fields dont need to be filled in. I just put a line of text in saying: Please ensure either Company Postcode, Agency Number or...
6
1721
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 tried a couple of code segments but they havnt been working. can anyone tell me how I can make fields in my code mandatory? My attempt at solving...
1
1381
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 remaining then , should be a warning display about the same..) <input type="radio" name="small" value="N" autocomplete="off" /> <input...
7
3168
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 of the four asp input field there are some field which the user cannot leave blank . we can know that mandatory field by the SQL table by checking the...
1
1711
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 will need to check each 20-30 text boxes if value is there or not !! Is there a way to do like define a class=mandatory and when it is found use...
0
7425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7682
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7935
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7449
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7780
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5351
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5069
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3479
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1037
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.