Lakshmitha
Lakshmitha

Reputation: 705

how to validate a dropdown list for checking textbox value before selecting dropdown in javaScript?

I've 1 textbox, its for getting DateTime value,First the user has to fill the DateTime textbox before selecting the vehicle dropdown. If that textbox is blank i ve to popup a message.. I am trying to validate but its not responding.. the code is,

function Validate_VehicleDropdown()
{
    var RequestDateTime=$get('<%=ui_txtRequestDateTime.ClientID %>')
    if(RequestDateTime.value=="")
    {
         alert("Please Enter RequestDateTime Before Selecting Vehicle");
         RequestDateTime.focus();
         return false;
    }

I called that function inside Dropdown control as

onblur="javascript:return Validate_VehicleDropdown();

What mistake i ve done here?? give some idea?

Upvotes: 1

Views: 935

Answers (2)

Mahesh KP
Mahesh KP

Reputation: 6446

you can use the onchange event instead of onblur

Upvotes: 1

Craig White
Craig White

Reputation: 14012

For one, you do not need to use javascript: in the blur part. That is primarily for hyperlinks. Secondly, perhaps you could check your browsers JavaScript logs for errors.

In Internet Explorer 9 press F12

In Firefox download firebug.

In Chrome press CTRL + SHIFT + J

Upvotes: 1

Related Questions