last day (14 days later) » 

5:32 AM
1
A: How to dynamically display a textbox and make it required based on radiobox selected

Vikas KumarYou're doing it wrong way. You should have a clear understanding of jQuery selectors. $('.MyTextBoxClass').css('required'); wouldn't work as you're selecting an HTML element, not the input field. Secondly, .css() is not what you're looking for. Do something like this to make it work: $(".MyTex...

 
This is the inspect element output that is getting generated now. <div class="col-md-10"> <input class="form-control" id="Email" name="Email" required="required" type="text" value=""> </div>
Still when I submit i do not see any error/validation message. Why so? Why am I still able to submit. Reqired = reuired. why it is not doing what it is supose to do.
Is there any additional steps/plugin required?
 
Yes. This is what you want? Now, if you will submit form without text in this input, it won't submit. Also, I would like to see how you're submitting form. That will help me see if you're doing things right or not.
Please post your form submit code. No plugins required. Improvements might be needed.
 
Added the code.
 
What do you see in HTML rendered in console. Is <form> tag generated properly? Without form tags, required wont' work. Can you give a link or attach a screenshot of HTML in console?
Yeah
 
You want me to give you the inspect element stuff
?
the complete inpect element code?
 
5:33 AM
Yes, if you can. Just for HTML. Only the input elements, checkboxes.
Or, code between body tags, precisely.
 
Ok, shall I paste it here?
or you knwo any link where I can put it
 
Add here jsfiddle.net and give me that link
You'll get the link when you click Save on top navbar
 
Yes, I know about it. Actuallt the form is really big. I wil have to alter it accrodingly
give me a moment
 
see if this helps you
Everything is working fine
Only problem is why am I still able to submit the form
class names are different, bear with me on that
But they are in sync
 
5:40 AM
Okay
 
You can clearly I see I am able to click on the submit button
 
I got the issue.
 
What is it?
I even have jquery client side validation active on my page
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
 
You have put the action url in your form element. I suggest you to read some data about submitting a form using jQuery. If you want the required to work, don't put action attribute. Just submit it using jQuery and ajax and provide the URL in ajax.
 
This form is not created by me
This form is created out of box by
ASP.NET MVC application
I don't think there will be any issue with that. just saying
 
5:45 AM
You need to read about it. I don't know much about this topic. But I'm sure this is the only problem.
 
Ok Vikash, Thank you for your time. thanks brother. :) Happy belated independence day. :)
 
Also, remove this novalidate="novalidate"
And use this: stackoverflow.com/questions/19454310/… This will definitely solve your problem. But still you'll need to read the basics so that you can understand things.
 
Sure. I will look into it.
 
Look Arjun's comment.
 
6:00 AM
Ya, that might be it. So all this I need to do just because I added something in the real time
I mean in general if we put some element and add it as required
thn it all works
why in thi case I need to take all this trouble
:/
What's so special in my code that I need to do all of that. I mean a general html file with required attriibute work like a charm
 

last day (14 days later) »