Clock input validation - angular7

I'd like to validate an input that should be in this format: 00:00 (hour:minutes) so no characters can be used, just a normal clock format! Any idea?
<input [(ngModel)]="item.time_in" [disabled]="isLock" value="{{ item.time_in }}" type="text" class="form-control">

Use the angular pattern validator with a regex that checks for the time:
(\d{2}):(\d{2})
The pattern validator allows you to check if your control's input matches a regex string.

Related

How to get user inputs from Jenkins Active Choice parameter using Formatted HTML

I defined parameter of type "Active Choices Reactive Reference Parameter" on Freestyle Job
it returns HTML text input - <input>.
but after populating this data and press "Build" i can't get the user input of this text field, tried with groovy or shell steps, for the parameter name itself i get empty string.
it's possible somehow to fetch the value of below field VAPP_ID ? suppose to get "123"
This is the groovy script of this Formatted HTML:
vappHtml = '''
<ul style="list-style-type: none">
<li>
<label for="VAPP_ID">VAPP_ID</label>
<input type="text" id="VAPP_ID" name="VAPP_ID">
</li>
</ul>
'''
return vappHtml
Finally i found what is the exact input definition needed to be able to fetch the data later in build steps.
groovy script:
vappHtml = '''
<ul style="list-style-type: none">
<li style="padding: 5px">
<label>VAPP_ID</label>
<input type="text" class="setting-input" name="value">
</li>
</ul>
'''
return vappHtml
How to actually fetch the data:
in build steps, like Shell, just get the original build parameter
in my case it's $Env_Details
i was missing for 2 mandatory attributes for the <input>
class="setting-input"
name="value" (the name must be 'value' and nothing else)
Note - In case you want to use multiple input fields, just give all of them the same name attribute: name="value", in the result, it will just give you all the fields values separated by "," delimiter, so you can split it in groovy or something.
Hope it will help someone :)

Field not displayed with condition

I use thymeleaf 3
I try to use a condition with th:attr with some value
<input type="text" class="form-control" th:id="'genericForm'+${genericField.field}" th:attr="${genericField.mandatory} ? data-msg=#{mandatory.field}, name=${genericField.field} : name=${genericField.field}"/>
Actually, this input is not displayed
error is:
Caused by: org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as assignation sequence:
Any idea?
Like this is how I would do it:
<input type="text" class="form-control" th:id="'genericForm'+${genericField.field}" th:name="${genericField.field}" th:attr="${genericField.mandatory} ? data-msg=#{mandatory.field}"/>
You can move name out to th:name since it's in both.

All radioButtons are false at the view

#Html.RadioButton("smth",true)
This row at the page looks like UNCHECKED radioButton. Why?
You should use
HtmlHelper.RadioButton(string name, object value, bool isChecked)
extension method.
First argument is the name of the form field which is input field generated by html helper.
Second argument is the value of input element. If this radio is selected when the postback to server happens, this value is used.
Third argument is what you are looking for. If it is true it makes radio button selected.
For instance,
#Html.RadioButton("Name", "Value" ,true)
would generate an input element which looks like following,
<input checked="checked" id="Name" name="Name" type="radio" value="Value" />
You need to use something of the form
#Html.RadioButton(id,value,checked (bool true/false))
So
#Html.RadioButton("A","B",true)
For example would produce:
<input checked="checked" id="A" name="A" type="radio" value="B" />
The documentation for this is here
In your previous query, you got this answer.
You asked the same query in it's comment section. The problem was that the second line of code was missing one parameter.
Please check below details....
Parameter Details
Razor Syntax
#Html.RadioButton("smth", "smth", true)
#Html.RadioButtonFor( m => m.Prop, true, new { id = "rdBtn" } )

HTML & ASP MVC 4: error CS1056: Unexpected character '\'

I am using asp mvc 4. I have the following html markup.
<input type="text" maxLength="2000" pattern="^(~/|https?://).*$|^mailto:([\w\.\-]+)#([\w\-]+)((\.(\w){2,3})+)$" >
I am receiving the following server error: HttpCompileException - error CS1056: Unexpected character '\'
I tried to escape it but it didn`t work. This must be simple but I am missing something. Any help will be greatly appreciated. Thanks!
Solution
The problem was in the # symbol. It should be escaped because it is used by the Razor view engine.
This works:
pattern="^(~/|https?://).*$|^mailto:([\w\.\-]+)#([\w\-]+)((\.(\w){2,3})+)$"
You may also use value of pattern's attribute as string literal:
<input type="text" maxLength="2000" pattern='#(#"^(~/|https?://).*$|^mailto:([\w\.\-]+)#([\w\-]+)((\.(\w){2,3})+)$")' >
//better:
#{
const string urlPattern = #"^(~/|https?://).*$|^mailto:([\w\.\-]+)#([\w\-]+)((\.(\w){2,3})+)$";
}
<input type="text" maxLength="2000" pattern="#urlPattern" >

Display label before input using formRow view helper in Zf2

In Zend Framework 2.1.4 I am using the standard form view helpers to render out my form elements.
When I try:
<?php echo $this->formRow($form->get('Title'));?>
The label text and input element are placed within the label:
<label>
<span>Title</span><input type="text" name="Title" placeholder="Inserisci titolo"
required="required" value="">
</label>
The same with:
<?php echo $this->formCollection($form, TRUE);
However, if I render out the label and input individually:
echo $this->formLabel($form->get('Title'));
echo $this->formInput($form->get('Title'));
It generates the html I want:
<label for="Title">Title</label>
<input type="text" name="Title" placeholder="Insert Title" required="required" value="">
How can I achieve the same with the formRow view helper?
If a form element does not have an "id" attribute, the label will wrap the input:
<label>Label<input /></label>
Otherwise:
<label for="test">Label</label><input id="test" />
Looking at (zf2 version 2.25 dev):
\Zend\Form\View\Helper\FormRow
It appears that if you don't provide an id for your form elements, the default general behaviour is to place the input element inside their corresponding label element.
The second argument for the formRow view helper, will place the label text before (prepend) or after (append) the input element in the document flow. (The default is to place it before.)
Check the render method for more details.
In first you must look source code to understand how formRow works : https://github.com/zendframework/zf2/blob/master/library/Zend/Form/View/Helper/FormRow.php
After you'll see in this code that __invoke has $labelPosition parameter that you can prepend or append with const LABEL_APPEND and LABEL_PREPEND.
In short, try to do something like this :
$this->formRorw($form->get('element'), 'prepend'); // Or append as you want

Resources