Click here to Skip to main content
16,016,425 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to add required="" element to textbox when button is clicked

What I have tried:

I'm tried
Attributes.Add("class",@"required=""");
Posted
Updated 3-Jun-16 20:59pm
Comments
Afzaal Ahmad Zeeshan 4-Jun-16 2:49am    
Why not use JavaScript?
ManiLancer 4-Jun-16 2:55am    
Required="" ,with textbox give good design ,also its default,so its better than JS

1 solution

try jquery
$(function() {
$( "#buttonid" ).click(function() {
  $("#textboxid").prop('required',false);
});
});
 
Share this answer
 
v6
Comments
ManiLancer 4-Jun-16 3:20am    
Thank you for ur answer,and How to call the function??and I have to do it for many textbox,is this method fit for that??
Jinesh N 4-Jun-16 4:05am    
yes, you just add cssclass instead of textboxid to do it for many textbox
ManiLancer 4-Jun-16 5:21am    
It Worked well thank you again..
ManiLancer 6-Jun-16 13:23pm    
Im used this code in content page,there other jQuerys are working fine but this jQuery not working ,pls give me some solutions
Jinesh N 8-Jun-16 5:04am    
please provide your code block.so there may be a clue.

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