Click here to Skip to main content
15,902,939 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am using master page with aspx page
and my design is in Bootstrap so can you please help me when i choose second field for fill data then it require please fill first field in

please help me

What I have tried:

i am using master page with aspx page
and my design is in Bootstrap so can you please help me when i choose second field for fill data then it require please fill first field in

please help me
Posted
Updated 7-Apr-17 21:41pm
Comments
Karthik_Mahalingam 8-Apr-17 1:13am    
use onblur Event[^] event to achieve that.
Member 12183079 8-Apr-17 1:43am    
sir i am fresher
and i want to give alert like if somebody select Second textbox then alter show please fill first textbox so kindly give me any url

1 solution

tr
<!DOCTYPE html>
<html>
<head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
</head>
<body>


    <script>
      
        function funcheck(txt) { 
             
            var key = parseInt(txt.getAttribute('key'));            
            var txts = document.getElementsByClassName('txtclass');
            for (var i = 0; i < txts.length; i++) {
                var attr = txts[i].getAttribute('key');
                if (attr) {
                    if (attr == key) {
                        $('.temp' + i).remove();
                        if (txts[i].value == '')
                            $(txts[i]).after(''">mandatory field!!')

                    }
                }
            }
        }
        

    </script>

    <input key="1" class="txtclass" type="text" onblur="funcheck(this); return false;" id="txt1" /> <br />
    <input key="2" class="txtclass" type="text" onblur="funcheck(this); return false;" id="txt2" /><br />
    <input key="3" class="txtclass" type="text" onblur="funcheck(this); return false;" id="txt3" />

 

</body>
</html>


Demo:- JSFiddle[^]
 
Share this answer
 
v2
Comments
Member 12183079 8-Apr-17 4:49am    
thanks
Karthik_Mahalingam 8-Apr-17 5:16am    
Welcome

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