0

I can't call my JavaScript using a freetextbox in asp.net.

Here's code my in JavaScript:

function validateFreetextbox()

{

    if(document.FTB_API["txt_Decs"].GetHtml == ''  )   

     {
        alert("Please Fill up desciption.");
        return false;
    }
    else
    {
        return true;
    }
}

My code's in asp.net for button:

<asp:Button ID="btn_Add" runat="server" OnClick="btn_Add_Click" Text="Add" 

Width="231px" Font-Size="11px" Font-Bold="false" ForeColor="#333333"  

onclientclick=" validateFreetextbox()" />
6
  • I think the problem is here if(document.FTB_API["txt_Decs"].GetHtml == '' ) Commented Mar 31, 2011 at 6:47
  • Can you show your complete code, I doubt you have different problem Commented Mar 31, 2011 at 7:15
  • @muhammad, i already put alert in the function start. Commented Mar 31, 2011 at 10:24
  • are you getting alert, if you put in the start of the funtion ? Commented Mar 31, 2011 at 10:50
  • I have edit my answer, check and let me know your findings. Commented Mar 31, 2011 at 10:58

1 Answer 1

3

should be onclientclick="validateFreetextbox();"

Edit: for your help, I have just created page at my end try and its working... can you make new page and check this at your end...

<html xmlns="http://www.w3.org/1999/xhtml">

<script language="javascript" type="text/javascript">
function validateFreetextbox()
{
alert('Called');
//    if(document.FTB_API["txt_Decs"].GetHtml == ''  )   
//    {
//        alert("Please Fill up desciption.");
//        return false;
//    }
//    else
//    {
//        return true;
//    }

}

</script>

</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:Button ID="btn_Add" runat="server"  Text="Add" Width="231px"
                Font-Size="11px" Font-Bold="false" ForeColor="#333333" OnClientClick="validateFreetextbox()" OnClick="btn_Add_Click" />
        </div>
    </form>
</body>
</html>
Sign up to request clarification or add additional context in comments.

7 Comments

can you put alert in the start of the function, then you will know whether function is called or not
@Muhammad Akhtar, i did, but nothing is change.
@Furqan, doesnt show anything.. it's directly saving in my database with empty value.
@SilverFang : try this, onClientClick="javascript:validateFreetextbox();"
@Furqan, its not working. i tried try it in vb.net its working using validateFreetextbox() but when i tried in C# it's not working..
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.