Click here to Skip to main content
15,877,966 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.

1 solution

Try This one :-

<html xmlns="" >
    <title>Untitled Page</title>
    <script type="text/javascript">
        function RegainFocus() {
            if((document.getElementById("txt").value).length == 0) {
                alert("The textbox should not be empty");
    <form id="frm">
        <input type="text" id="txt" >
<input type="button" value=" Click " onclick="javascript:RegainFocus();"/>
Share this answer
ujali 14-Mar-13 9:18am    
this is not working...
Sumit_Kumar_Sinha 14-Mar-13 9:43am    
you are using 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