.NET Framework Bookmark and Share   
 index > JScript for the .NET Framework > Validation Select Button Issue
 

Validation Select Button Issue

Hello,

I am using a drop down menu and dynamically populating it with a mysql database. I am trying to validate to make sure that user selects a list of names from the menu. However, I am unsuccessful. I am trying with javascript. Here are section of my code.

function SelectCustomer()
{
if (!document.PendingCustomerInfo.Select.value)
{
alert("Please select a customer.");
return false;
}
else
{
return true;
}
}

<select name = "Select" align = "center">
<option value = "0" selected>Select Customer</option>

much appreciation on any suggestions.

BananaTree

Hi,

What is PendingCustomerInfo ?

Anyway you should use getElementById for this case, for example:

Code Snippet

<select id="Select1">
<option value="0">aaa</option>
<option value="1">bbb</option>
<option value="2">ccc</option>
</select>

<script type="text/jscript">
function test()
{
if (!document.getElementById("Select1").value)
{
alert("Please select a customer.");
return false;
}
else
{
alert("selected");
return true;
}
}
</script>

Thanks

Figo Fei

Hi,

What is PendingCustomerInfo ?

Anyway you should use getElementById for this case, for example:

Code Snippet

<select id="Select1">
<option value="0">aaa</option>
<option value="1">bbb</option>
<option value="2">ccc</option>
</select>

<script type="text/jscript">
function test()
{
if (!document.getElementById("Select1").value)
{
alert("Please select a customer.");
return false;
}
else
{
alert("selected");
return true;
}
}
</script>

Thanks

Figo Fei

You can use google to search for other answers

Custom Search

More Threads

• XMLHttpRequest.status 122 instead of 200
• invoking given javascript google map code from vb.net button click
• Calling JS function within C#
• does ICodeCompiler need SDK?
• devEdit attributes
• ASP.NET - DropDownList.SelectedValue is NULL, Why ?
• Jscript and separating instances thereof for animations
• Newbie - VBS script error
• Event Bubbling
• marquee with huge string