Click here to Skip to main content
15,905,427 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
all textbox is in itemtemplate of template field,i want to that field should make compulsory by using javascript,

please help me.
Posted

1 solution

Try This one :-

XML
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Untitled Page</title>
    <script type="text/javascript">
    <!--
        function RegainFocus() {
            if((document.getElementById("txt").value).length == 0) {
                document.getElementById("txt").focus();
                alert("The textbox should not be empty");
            }
        }
    //-->
    </script>
</head>
<body>
    <form id="frm">
        <input type="text" id="txt" >
<input type="button" value=" Click " onclick="javascript:RegainFocus();"/>
    </form>
</body>
</html>
 
Share this answer
 
Comments
ujali 14-Mar-13 9:18am    
this is not working...
Sumit_Kumar_Sinha 14-Mar-13 9:43am    
you are using asp.net textbox control or html

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900