I have a problem as mentioned in the title.
The input field is of type number.
The th:field refers to an int attribute in the database.
I want my placeholder to be visible instead of the default 0 value.
<input id="courseCredits" name="courseCredits" th:field="*{courseCredits}" class="form-control" placeholder="Course Credits" type="number" min="0" required autofocus/>
If you don't want the default of 0 you can't use an int. Instead use an Integer with null for empty.
Change 'int' to 'Integer' in your entity class.
Related
I need to prevent negative values in Kendo numeric textbox template as below:
<input type="text" data-type="number" data-format="n0" name="SnoozeLength" data-bind="value:snoozeLength" data-role="numerictextbox" />
is there any attributes which i can use line "min-value= 0"
Try with the following:
http://docs.telerik.com/kendo-ui/api/web/numerictextbox#configuration-min
You can specify min configuration for your numerictextbox.
Best Regards,
i have a text box in my web application,Where i need to give input. I am trying to find the xpath of the text box. the following error is thrown.
Unable to locate element: {"method":"xpath","selector":"
HTML code:
<div class="input">
<input id="firstName" class="long" type="text" maxlength="50" value="" name="firstName
I want the xpath for firstName textbox.
//input[#type='text']
And this for generally targeting a text input (what I was after)
Try this one:
//input[#id='firstName']
Explanation:
// search on all levels
input for element nodes with the name of "input"
[#id='firstName'] having an attribute (#) with the name of "id" and a value of "firstName"
at least 3 simple ways to get this:
1)Driver.FindElement(By.XPath("//input[#id='firstName']"));
2)Driver.FindElement(By.Id("firstName"));
3)Driver.FindElement(By.CssSelector("#firstName"));
//*[text()[contains(.,'firstName')]]
finding by text would always work.
hi i am using codeigniter . i have a form , there i add hidden fields dynamically . so every hidden field is <input type='hidden' name='hidden' value="+$(this).attr('title')+"> so the name is equal .
the problem is when i submit the form and try to get my hiden field values i can only get one hidden field value , because the names are same
i print my form values
print_r($this->input->post());
i have 2 hidden fields but i get only one
Array
(
[hidden] => march
[textbox] => march
[mysubmit] => Submit
)
i can change the name dynamically of hidden field when creating , but then i don't know exactly the name of my hidden field ,
how can i get hidden field values with same name ?? is there any way to get form values other than by name ?? i tried and can not find an answer , please help .............
You'll need to use brackets in your name attributes:
<input type='hidden' name='hidden[]'>
<!-- ^^^^ -->
This will allow PHP to accept multiple inputs with the same name as an array of values, so in this case, $_POST['hidden'] will return an array of strings.
By default they are indexed starting at 0, so $_POST['hidden'][0] will get you the first one, $_POST['hidden'][1] will get you the second, etc., however - you can explicitly index them if it's easier for you, either with numbers or strings.
<input type='hidden' name='hidden[first]'>
<input type='hidden' name='hidden[second]'>
Or:
<input type='hidden' name='hidden[0]'>
<input type='hidden' name='hidden[1]'>
You can nest these as deep as you want like hidden[first][1][], and they will be treated similarly to a PHP array when you get the $_POST values, but you need the brackets in the HTML.
Without brackets, only the last field's value will be available in the $_POST array. This is a PHP feature, Codeigniter can't do anything about it.
I want to restrict entry of input onto a field of type number such that input cannot be outside range of min-max specified in the html.
input type = "number" min = "1" max = "5"
Is there a way of outputting the number field without the text box and i would rather not use
"input type = range"
as slider does not show value currently selected
Please help.
Thanks.
Based on what you said, I suggest using a simple input text field and check it's value validity on submission via JavaScript (as #Kush mentions above). You could also check it as the user types, or moves focus away from that field.
<form>
Only 1 to 100 <input type="text" name="number" pattern="\d{1,2}(?!\d)|100" title="one to hundreed only">
<input type="submit">
</form>
//input[#type="hidden" and #name="val" and position() = 1]/#value
does this mean get the text typed inside the input box ?
Read from right to left, it means "Get the value attribute of all of the input tags whose type attribute is 'hidden', whose name attribute is 'val', and which appears as the first element in its enclosing (form) tag".
I think it means grab the value attribute of an input whose type attribute is 'hidden' in addition its name attribute is 'val' and its position amongst its siblings is 1 ( first I believe, not sure if 0 is the start in xpath ).
<input type="hidden" name="val" value="test">
<input type="hidden" name="foo">