forms

Django form errorlist render position

廉价感情. 提交于 2020-01-22 12:33:47
问题 When I display a form with errors using {{ f.as_p }} , the errorlist ul always comes first then the label and input field. For example: <ul class="errorlist"> <li>This field is required.</li> </ul> <p> <label for="id_content">Content:</label> <textarea id="id_content" class="required error" name="content" cols="80" rows="10"/> </p> I know you can use {% for field in f %} <p>{{ field.label_tag }}: {{ field }}</p> {{ field.errors }} {% endfor %} To change the errorlist ul position after label

How to protect a contact form without captcha?

六月ゝ 毕业季﹏ 提交于 2020-01-22 10:24:18
问题 On my website I have a couple of forms where someone (without registration) can send message to specified, registered user. The form is simple, and I want to keep that way. What is the best way to protect a contact form againts spam and bots if I don't want to use any captcha? Your message:... Your e-mail:... [Send] 回答1: So the options: Maximize query/IP Add security question Captcha (even if you don't like it) Sending e-mail to validate it Submitting data via JavaScript Details on these and

How to protect a contact form without captcha?

做~自己de王妃 提交于 2020-01-22 10:23:05
问题 On my website I have a couple of forms where someone (without registration) can send message to specified, registered user. The form is simple, and I want to keep that way. What is the best way to protect a contact form againts spam and bots if I don't want to use any captcha? Your message:... Your e-mail:... [Send] 回答1: So the options: Maximize query/IP Add security question Captcha (even if you don't like it) Sending e-mail to validate it Submitting data via JavaScript Details on these and

Check all elements in form with Javascript

北城余情 提交于 2020-01-22 09:59:33
问题 I know javascript in the beginning level, but I have a problem. I have 7 input elements in a form and I want all of them to be filled. I came up with this idea but it looks disgusting . Can someone help me how to check whether all form elements are filled or not? function validateForm() { var x=document.forms["register"]["name"].value; var y=document.forms["register"]["phone"].value; var z=document.forms["register"]["compname"].value; var q=document.forms["register"]["mail"].value; var w

Check all elements in form with Javascript

孤者浪人 提交于 2020-01-22 09:57:27
问题 I know javascript in the beginning level, but I have a problem. I have 7 input elements in a form and I want all of them to be filled. I came up with this idea but it looks disgusting . Can someone help me how to check whether all form elements are filled or not? function validateForm() { var x=document.forms["register"]["name"].value; var y=document.forms["register"]["phone"].value; var z=document.forms["register"]["compname"].value; var q=document.forms["register"]["mail"].value; var w

Creating Yii FormModel objects (CFormModel) dynamically

自作多情 提交于 2020-01-22 08:05:27
问题 I'm working on an application that involves generating forms at a high level of abstraction (it's a CMS app). I want to dynamically create CFormModel objects and set the form fields on-the-fly. I think I can do this by extending CFormModel, and then dynamically creating the class properites that represent the form fields ('attributes' in the Yii lingo). To illustrate, instead of specifying a login form in the following class (defined in a file): // From: http://www.yiiframework.com/doc/guide

Creating Yii FormModel objects (CFormModel) dynamically

社会主义新天地 提交于 2020-01-22 08:05:02
问题 I'm working on an application that involves generating forms at a high level of abstraction (it's a CMS app). I want to dynamically create CFormModel objects and set the form fields on-the-fly. I think I can do this by extending CFormModel, and then dynamically creating the class properites that represent the form fields ('attributes' in the Yii lingo). To illustrate, instead of specifying a login form in the following class (defined in a file): // From: http://www.yiiframework.com/doc/guide

Creating Yii FormModel objects (CFormModel) dynamically

非 Y 不嫁゛ 提交于 2020-01-22 08:04:21
问题 I'm working on an application that involves generating forms at a high level of abstraction (it's a CMS app). I want to dynamically create CFormModel objects and set the form fields on-the-fly. I think I can do this by extending CFormModel, and then dynamically creating the class properites that represent the form fields ('attributes' in the Yii lingo). To illustrate, instead of specifying a login form in the following class (defined in a file): // From: http://www.yiiframework.com/doc/guide

Angular 4 remove required validator conditionally

别来无恙 提交于 2020-01-22 07:11:05
问题 In Angular 4 app I have a form model like this: this.form = this._fb.group({ title: ['', [Validators.required, Validators.minLength(3), Validators.maxLength(50)]], description: ['', [Validators.required, Validators.minLength(3)]] }); Now what I want is to remove dynamically only the required validator from the control validators array. Something like this: saveDraft() { this.form.controls['title'].removeValidator('required'); //Just a fake implementation for demonstration } This question is

Creating <select> elements in React JS

我的梦境 提交于 2020-01-22 05:49:05
问题 I'm rewriting the UI for my web-app in react.js, and I'm a bit stumped by the following problem. I have a page which displays data obtained via an AJAX request, and below that, a form to submit new data is displayed. All good. Now, I want to add a <select> element to the form, and fetch the values from a different location (url). The current code (without the <select> ) looks like this (simplified a bit, but all the working details are the same; it mostly follows the tutorial on the react.js