required

make a input field required if radio is checked

浪子不回头ぞ 提交于 2019-12-04 17:10:07
问题 Can I somehow insert the required attribute into an input field only if a certain radio is checked? I have an input field named "ladder-meters" that is not required to be filled per default. But if the user checks a radio button that is named "ladder" the "ladder-meters" field are required to be filled. My input looks like this: <input type="text" name="ladder-meters" id="ladder-meters"> and should like this at the onchange event on the radio <input type="text" name="ladder-meters" id="ladder

Required input field gets border when value is empty and color is styled

核能气质少年 提交于 2019-12-04 13:43:12
Could you explain me this? Run this in Firefox: http://jsfiddle.net/eMa8y/24/ HTML: <html> <head> <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> </head> <body> <form> <input type="text" placeholder="input" required /> <input type="text" placeholder="input" /> </form> </body> </html> CSS: input { color:black; } [required] { color:red; } SCRIPT: $(document).ready(function () { setTimeout(function () { $("input").val(""); }, 3000); }); Wait three seconds and the input gets a red border. Why? Is it a bug of Firefox? Note that I use Firefox 18.0.2. Thanks. Liam The HTML5

Django: Make certain fields in a ModelForm required=False

点点圈 提交于 2019-12-04 08:51:59
问题 How do I make certain fields in a ModelForm required=False? If I have: class ThatForm(ModelForm): class Meta: widgets = {"text": Textarea(required=False)} Or if I have: class ThatForm(ModelForm): text = Textarea(required=False) Django returns: __init__() got an unexpected keyword argument 'required' 回答1: following from comments. Probably yes: class ThatForm(ModelForm): def __init__(self, *args, **kwargs): # first call parent's constructor super(ThatForm, self).__init__(*args, **kwargs) #

Knockout Validation onlyif object no function and pattern validation

瘦欲@ 提交于 2019-12-04 05:41:48
问题 I want to the priceMax was required, when title is empty. I have code self.searchParameters = { title: ko.observable().extend({ refreshCountOffers: 500 }), priceMax: ko.observable().extend({ required: { onlyIf: function() { return title==null; } }, refreshCountOffers: 500 }) }; ,but I get error 'title is not defined'. How to disable option, which show error for pattern validation, when user input first letter? postCode: ko.observable().extend({ required: true, pattern: { message: 'Post code

How can I cross-browser detect input fields with the 'required' attribute in jQuery?

删除回忆录丶 提交于 2019-12-04 03:39:56
问题 I am running into a slight validation issue with the Boolean required attribute on form fields. I am marking up my fields as such: <label for="email">Email Address:</label> <input value="" type="email" name="email" id="email" required /> But trying to find all required fields using jQuery and adding them to an array seems problematic due to detection issues. The following only works in Firefox (Gecko) $(':input[required=""]') but returns nothing in Webkit (Safari, Chrome). Webkit on the other

Javascript Validation for all field with Required attribute

元气小坏坏 提交于 2019-12-04 02:33:51
I've searched high and low for the answer to this but can't find it anywhere. I have a form which has the HTML 'required' attributes and it does a fine job of highlighting the fields that need to filled in before submission...or would do, but the system which my form is bolted onto (of which I have no control over) submits the form anyway after a few seconds. It relies on Javascript for it's submission. Therefore I'd like to write a Javascript script to check all fields for a required attribute. Currently I have a script that specifies the fields I want to be mandatory, but if it could look up

at least one field is required in angular 4 forms

北城余情 提交于 2019-12-03 17:19:05
I'm using angular 4 forms and I have some fields. and first_name, last_name and company are really important for me. I want to force the user to fill one of these 3 fields. how can I do it? here are .ts codes: this.contactForm = this.fb.group({ first_name: [null, Validators.compose([Validators.required])], last_name: [null, Validators.compose([Validators.required])], email: [null, Validators.compose([this.validateEmail])], company: [null], position: [null], }); an html: <form [formGroup]="contactForm" fxLayout="column"> <md-input-container class="data_light"> <input class="data_font capital"

Django: Make certain fields in a ModelForm required=False

梦想的初衷 提交于 2019-12-03 04:24:27
How do I make certain fields in a ModelForm required=False? If I have: class ThatForm(ModelForm): class Meta: widgets = {"text": Textarea(required=False)} Or if I have: class ThatForm(ModelForm): text = Textarea(required=False) Django returns: __init__() got an unexpected keyword argument 'required' following from comments. Probably yes: class ThatForm(ModelForm): def __init__(self, *args, **kwargs): # first call parent's constructor super(ThatForm, self).__init__(*args, **kwargs) # there's a `fields` property now self.fields['desired_field_name'].required = False you ought to add blank=True

Validate input as required only if certain command button is pressed

久未见 提交于 2019-12-03 03:59:55
I have specific use case for JSF validation. For example I have an inputText field: <p:inputText id="input" required="#{myBean.required}" value="#{myBean.value}" maxlength="20" disabled="#{myBean.disabled}"> <p:ajax event="blur" process="@this" update="name" listener="#{myBean.listener}"/> </p:inputText> Value of input is number (in some cases it can also be a string, because this is part of composite component, but problem is better described if we assume this is a number). This input is part of the form, at the end of form I have submit button: <p:commandButton value="Save" actionListener="#

Rails simple_form attribute required mark (*)

拥有回忆 提交于 2019-12-03 03:41:56
问题 I am using Simple Form in my app and I'd like to remove the * to indicate an attribute is required on all of my forms (existing and those yet to be created). I have tried to set in simple_form.rb : # Whether attributes are required by default (or not). Default is true. config.required_by_default = false And I've tried to modify simple_form.en.yml : required: text: 'required' mark: '' # <------ tried setting this to blank. I know I can set :required => false on each field, but I want to clean