user3262364 user3262364 - 7 months ago 20
HTML Question

not able to validate text box using java script

my input text box source like this:

<asp:TextBox ID="TxtDepCode" runat="server" Height="18px"></asp:TextBox>

and my javascript function like this:

<script type="text/javascript" language="javascript">
function confirm_user() {
var userPass = document.getElementById('TxtDepCode');
if (userPass=''){
alert("value is blank")
if (confirm("Department already available, would you like to update ?") == true)
return true;
return false;

in submit button click i want to check wethar corresponding text is empty or not
my submit button click event like this:

var userPass = document.getElementById('TxtDepCode').value;


var userPass = document.getElementById('<%=TxtDepCode.ClientID%>').value;

Modify the first line of function to get value of textbox as above

if (userPass==''){

Modify if as above