form-fields

Using Javascript to Open a New Page and Populate Form Values There

时光毁灭记忆、已成空白 提交于 2019-12-18 03:49:07
问题 I am using JavaScript in a bookmarklet to populate form elements on a website: javascript:var f = document.forms[0]; f.getElementsByTagName('input')[0].value = 'myname'; f.getElementsByTagName('input')[1].value = 'mypassword'; f.getElementsByTagName('input')[2].click This works. However what I would like to create is a bookmarklet so that it opens the target page, and populates the values there; however it seems that onces the page is loaded, other JavaScript codes are not executed. So, the

Django: How to write a clean method for a field that allows mutiple file uploads?

浪尽此生 提交于 2019-12-08 01:11:00
问题 I have a form for uploading images. If I follow Django's standard for cleaning a specific field attribute of a form, this is what my clean method would typically look like: class UploadImagesForm(forms.Form): image = forms.FileField() def clean_image(self): file = self.cleaned_data['image'] if file: if file._size > 15*1024*1024: raise forms.ValidationError("Image file is too large ( > 15mb ).") return file else: raise forms.ValidationError("Could not read the uploaded file.") However, I'm

Django: How to write a clean method for a field that allows mutiple file uploads?

强颜欢笑 提交于 2019-12-06 12:42:41
I have a form for uploading images. If I follow Django's standard for cleaning a specific field attribute of a form , this is what my clean method would typically look like: class UploadImagesForm(forms.Form): image = forms.FileField() def clean_image(self): file = self.cleaned_data['image'] if file: if file._size > 15*1024*1024: raise forms.ValidationError("Image file is too large ( > 15mb ).") return file else: raise forms.ValidationError("Could not read the uploaded file.") However, I'm using a form that allows multiple images to be uploaded at once, all through the same widget (ie, the

Django: Display NullBooleanField as Radio and default to None

試著忘記壹切 提交于 2019-12-04 12:38:21
I am successfully implementing NullBooleanField as radio buttons in several ways but the problem is that I can not set the default value to None. Here is the code: models.py: class ClinicalData(models.Model): approved = models.NullBooleanField() ... forms.py: NA_YES_NO = ((None, 'N/A'), (True, 'Yes'), (False, 'No')) class ClinicalDataForm(ModelForm): approved = forms.BooleanField(widget=forms.RadioSelect(choices=NA_YES_NO)) class Meta: model = ClinicalData I tried the following methods: Set default:None in the model and/or setting inital:None in the form and also in the view in the form

Use Sonata Field Type on normal Form Class

血红的双手。 提交于 2019-12-03 17:22:43
I'm trying to insert custom sonata form field type on the front page, not in SonataAdmin, something like this: $form = $this->createFormBuilder($content) ->add('titleEs', 'text', array('required' => true, 'label' => 'label.title.spanish', 'attr' => array('class' => 'col-xs-12 form-control input-lg'))) ->add('contentEs', 'ckeditor', array('required' => true,'label' => 'label.content.spanish', 'attr' => array('class' => 'col-xs-12'))) ->add('titleEn', 'text', array('required' => true,'label' => 'label.title.english', 'attr' => array('class' => 'col-xs-12 form-control input-lg'))) ->add(

How to turn off html input form field suggestions?

喜欢而已 提交于 2019-12-03 04:06:21
问题 By suggestions I mean the drop down menu appear when you start typing, and it's suggestions are based on what you've typed before: for example when I type 'a' in title field, it will give me a ton of suggestions which is pretty annoying.Does anyone know how to turn that off? Thanks in advance. 回答1: What you want is to disable HTML autocomplete Attribute. Setting autocomplete="off" here has two effects: It stops the browser from saving field data for later autocompletion on similar forms

Adding asterisk to required fields in Bootstrap 3

心已入冬 提交于 2019-12-03 01:30:43
问题 My HTML has a class called .required that is assigned to required fields. Here is the HTML: <form action="/accounts/register/" method="post" role="form" class="form-horizontal"> <input type='hidden' name='csrfmiddlewaretoken' value='brGfMU16YyyG2QEcpLqhb3Zh8AvkYkJt' /> <div class="form-group required"> <label class="col-md-2 control-label">Username</label> <div class="col-md-4"> <input class="form-control" id="id_username" maxlength="30" name="username" placeholder="Username" required=

How to turn off html input form field suggestions?

China☆狼群 提交于 2019-12-02 17:26:34
By suggestions I mean the drop down menu appear when you start typing, and it's suggestions are based on what you've typed before: for example when I type 'a' in title field, it will give me a ton of suggestions which is pretty annoying.Does anyone know how to turn that off? Thanks in advance. What you want is to disable HTML autocomplete Attribute. Setting autocomplete="off" here has two effects: It stops the browser from saving field data for later autocompletion on similar forms though heuristics that vary by browser. It stops the browser from caching form data in session history. When form

Adding asterisk to required fields in Bootstrap 3

醉酒当歌 提交于 2019-12-02 13:49:05
My HTML has a class called .required that is assigned to required fields. Here is the HTML: <form action="/accounts/register/" method="post" role="form" class="form-horizontal"> <input type='hidden' name='csrfmiddlewaretoken' value='brGfMU16YyyG2QEcpLqhb3Zh8AvkYkJt' /> <div class="form-group required"> <label class="col-md-2 control-label">Username</label> <div class="col-md-4"> <input class="form-control" id="id_username" maxlength="30" name="username" placeholder="Username" required="required" title="" type="text" /> </div> </div> <div class="form-group required"><label class="col-md-2

Unable to read form field in servlet [duplicate]

我是研究僧i 提交于 2019-12-01 23:22:08
问题 This question already has answers here : How to upload files to server using JSP/Servlet? (12 answers) Closed 4 years ago . Hey I am quite new to servlet environment. Here I am trying to post a form to my servlet with something like this: <form action="OnlineExam?q=saveQuestion" method="post" enctype="multipart/form-data"> <fieldset> <legend>Question</legend> <textarea class="questionArea" id="question" name="question">Enter Question.</textarea> <br class="clearFormatting"/> Attach File<input