This is my html file
I want red borders on form submit on invalid fields using django template language
I want red borders on form submit on invalid fields using django template language
I want red borders on form submit on invalid fields using django template language
{% block body %} {% include 'navbar.html'%}
<!DOCTYPE html>
<html>
<head>
<title></title>
<body>
<form autocomplete="off" method="POST" enctype="multipart/form-data">
{% csrf_token %}
<div >
<label for="Title" >Title</label>
{{form.title}}
<div >{{form.title.errors}}</div>
</div>
<div >
<label for="Written By" >Written by</label>
{{form.written_by}}
<div >
{{ form.written_by.errors }}
</div>
</div>
<div >
<label for="Description" >Description</label>
{{form.description}}
<div >{{form.description.errors}}</div>
</div>
<div >
<label for="image" >Image</label>
{{form.image}}
<div >{{form.image.errors}}</div>
</div>
<button type="submit" >Submit</button>
</form>
<style>
.form-control {
width: 50%;
}
.errorlist {
list-style-type: none;
color: red;
position: relative;
right: 31px;
}
form {
margin-left: 30%;
margin-right: 30%;
}
textarea {
height: 4em;
width: 50em;
}
</style>
</body>
</head>
</html>
{% endblock %}
I want red borders on form submit on invalid fields using django template language
I want red borders on form submit on invalid fields using django template language
I want red borders on form submit on invalid fields using django template language
CodePudding user response:
One way to achieve this would be writing the entire form fields yourself. For example, for your {{form.title}}
, you could use:
<input type="text" name="{{form.title.html_name}}" id="{{form.title.id_for_label}}" >
Then in your styles:
.invalid-input {
border-color: red;
}