4๐
โ
I have created a fiddle using your code that how you can apply required on the filed.
See this: fiddle example
You need to add two more lines in JS:
$(document).ready(function(){
$("select").change(function(){
$(this).find("option:selected").each(function(){
var optionValue = $(this).attr("value");
console.log(optionValue);
if(optionValue){
$(".col").not("." + optionValue).hide();
$("." + optionValue).show();
$('input[type="text"]').removeAttr('required');
$("." + optionValue + " input").attr('required','true');
} else{
$(".col").hide();
}
});
}).change();
});
๐คAbdul Rauf
1๐
if(optionValue){
$(".col").not("." + optionValue).hide();
$(".col").not("." + optionValue).removeAttr('required');โโโโโ
$("." + optionValue).show();
$("." + optionValue).attr('required', true);
}
๐คccesare
- [Django]-Django problem with extends template tag
- [Django]-How to solve "table "auth_permission" already exists" error when the database is shared among two Django projects
- [Django]-Django rest framework โ session auth vs token auth, csrf
- [Django]-Returning Hex UUID as default value for Django model charfield
- [Django]-Querying for timestamp field in django
Source:stackexchange.com