redho home | products | services

Programming Forums


Community for Java, PHP, Perl C, ASP and Python programmers
Monday 06 September 2010 14:10

Ask your IT question here

Multiple Drop Down Validation



 
Post new topic   Reply to topic    Programming Forums -> JavaScript forum
View previous topic :: View next topic  
Author Message
Jake
Enthusiastic Coder


Joined: 15 Mar 2005
Posts: 68
The code below is a working code to validate an empty selection in the drop down list.

What changes I must do in the Form OnSubmit if I want to validate more that one dropdown list in my form.

How many script can a page handle at one time! I mean the javascript that we put in the <head></head> section? Is there any limit?

Code:
<html>
<head>
<title>Untitled Document</title>
<script language="javascript">
function fCheck(val1){
if (val1 == ""){
alert("Please select a value");
return false
}else{
return true
}
}
</script>
</head>

<body>
<form action="http://www.mcfc.co.uk" method="post" onSubmit="return fCheck(bnRoom.value);">
<select name="bnRoom">
<option></option>
<option value="MONDAY">MONDAY</option>
<option value="TUESDAY">TUESDAY</option>
<option value="MONDAY">WEDNESDAY</option>
<option value="THURSDAY">THURSDAY</option>
<option value="FRIDAY">FRIDAY</option>
</select >
<input type="submit" value="click me!">
</form>
</body>
</html>

Reply with quote
 
Jony
Enthusiastic Coder


Joined: 18 Mar 2005
Posts: 71
I believe that each object in your form can use onfocus() and onblur() which will be called each time someone clicks onto (focuses) on an object and clicks off of (blurs) an object.

Using that, you could make it so that required fields automatically alert the user when they are not filled in.

Of course, if the user doesn't click on them then they never get the message... I don't believe that you can call more than one function from onSubmit though, so you would have to design another function which explicitly tested your form and each of the required fields.

Reply with quote
 
Page 1 of 1
Post new topic   Reply to topic    Programming Forums -> JavaScript forum


Dubai Forums - Expat Help | Vegan Forum | Java Programming | 3d Design Resources | 3d Forum | 3D Jobs | 3D Textures | Paris Forum | Europe Forum
Dubai Classifieds | Dubai Property | Jobs in Dubai | Free London Classifieds | Jobs in London UK

High Quality, Custom 3d animation and Web Design solutions Royal Quality Web Hosting Services Vegetarian and Animal Rights news

Based on phpBB © 2001-2010 RedHo