How to use validate-digits-range validation in magento? - validation

Hi Friends I want to validate number range in magento. I also got validation class validate-digits-range. But i don't know to how to pass that minimum and maximum value for that validation.
If anybody know means kindly share that example. Thanks in advance

You should use in text form field like :
... class="required-entry validate-digits-range digits-range-10-20"...
This will validate the value to be between 10 and 20.

See the following example for a range between 1 and 50:
validate-number-range number-range-1-50
<field id="radius" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Delivery radius</label>
<validate>validate-number validate-number-range number-range-1-50</validate>
</field>

Related

Regular Expression - How to validate price field if I enter below 30?

I have used pattern I want to price equal 30 or Greater BUT not less.
Look my html code -
<input type="text" required="required" pattern="29+\.[0-9]*[1-9][0-9]*$" data-error="#Please enter price equal 30 or more" placeholder="Price" id="price" class="form-control" autocomplete="off" name="price" />
<div class="help-block with-errors"></div>
Above co I have used pattern="29+\.[0-9]*[1-9][0-9]*$" but this pattern not working. I have tried in different expression like 29*\.[0-9]*[1-9][0-9]*$, ^\d{30,}$, ^[0-9]\{30,}\$ these expressions also not working.
I am using bootstrap validator. Link = http://1000hz.github.io/bootstrap-validator/#validator-examples
Please help me.
*Edit : *
Now I am using ^[3-9]+\d*$ this is working fine. But it takes 3 or more than 3. I need 30 or more
You really should not be using regexes for this kind of task. But if you do want to, try this:
([3-9][0-9]|[0-9]{3,})

AXMLS check constraint

I am creating q site using Conreate 5 CMS.
I am creating a new block and I have to use AXMLS to create a database table.
I have been able to create a basic table but I would like to extend it to add an check constraint. Below is the code I have written so far.
<?xml version="1.0"?>
<schema version="0.3">
<table name="btAddVehicle">
<field name="bID" type="I">
<key />
<unsigned />
</field>
<field name="title" type="C" size="100">
<NOTNULL />
</field>
<field name="imgLocation" type="X"></field>
<field name="year" type="I" size="4"></field>
<field name="desciption" type="X"></field>
</table>
</schema>
so for the line I was intending to that size="4" would restrict the number of values to 4. eg 1990,1999 but this didn'st work
I have read this http://phplens.com/lens/adodb/docs-datadict.htm#foreignkey
but it seems unclear
It says
CONSTRAINTS Additional constraints defined at the end of the field definition."
SO would it be something like
<field name="year" type="I" constraint="check([year] LIKE REPLICATE ('[0-9]', 4)) "></field>
Or do I need to add an at the end of this code
`<sql>
add some kind of alter table to add the constraint
AlTER tblTable etc....
</sql>`
The size=4 only restrict it to a number between 0 and 9999. So no, that won't work.
I don't know how to use CONSTRAINTS either, but I have never needed that. Normally I use Concrete5's validation helper to validate values before saving them to the database. This also makes it a lot easier to get it printed out to the user in your view, if needed, using the validation error helper
Hope this helps you...

Set min value for numeric textbox in Kendo ui template

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,

XPATH required for an input text field?

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.

Validating input type number in html5

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>

Resources