留言板
In alloy-ui how to validate select field....
Ramya Sree Kalagiri,修改在11 年前。
In alloy-ui how to validate select field....
New Member 帖子: 8 加入日期: 12-12-19 最近的帖子
Hi all,
how to validate select field as mandatory only when it's corresponding text field is entered?
For example
<aui:form name="temp">
<aui:input type="text" name="temperature"/>
<aui:select label="" name="unit">
<aui:option value="" >--select--</aui:option>
<aui:option value="hello">Celcius</aui:option>
<aui:option value="hello hi">Fahrenheit </aui:option>
</aui:select>
<aui:input type="submit" name="submit"/>
</aui:form>
Here using alloy-ui validations how to generate validation error when temperature is entered but unit has not chosen?
Note:It is not mandatory that always temperature should be entered
can any please help me out.....
how to validate select field as mandatory only when it's corresponding text field is entered?
For example
<aui:form name="temp">
<aui:input type="text" name="temperature"/>
<aui:select label="" name="unit">
<aui:option value="" >--select--</aui:option>
<aui:option value="hello">Celcius</aui:option>
<aui:option value="hello hi">Fahrenheit </aui:option>
</aui:select>
<aui:input type="submit" name="submit"/>
</aui:form>
Here using alloy-ui validations how to generate validation error when temperature is entered but unit has not chosen?
Note:It is not mandatory that always temperature should be entered
can any please help me out.....
Hitoshi Ozawa,修改在11 年前。
RE: In alloy-ui how to validate select field....
Liferay Legend 帖子: 7942 加入日期: 10-3-24 最近的帖子
Check the following page to see form validation with alloy ui.
http://rajeevalochanabr.wordpress.com/2012/08/20/validation-using-auialloy-user-interface-script-and-html-form/
http://rajeevalochanabr.wordpress.com/2012/08/20/validation-using-auialloy-user-interface-script-and-html-form/
Ramya Sree Kalagiri,修改在11 年前。
RE: In alloy-ui how to validate select field....
New Member 帖子: 8 加入日期: 12-12-19 最近的帖子
Hi,
thank you for the reply. I know how to validate select as required. But I want to know how validation on select will be done only when the text field(temperature) is entered.
thank you for the reply. I know how to validate select as required. But I want to know how validation on select will be done only when the text field(temperature) is entered.
Ramya Sree Kalagiri,修改在11 年前。
RE: In alloy-ui how to validate select field....
New Member 帖子: 8 加入日期: 12-12-19 最近的帖子
Can any one please solve my question soon? I need it urgently.... thanks in advance.
Joe Pinto,修改在9 年前。
RE: In alloy-ui how to validate select field....
New Member 帖子: 4 加入日期: 14-2-21 最近的帖子
I may be a little late here...
try to think it like this:
instead of saying 'this field is always required' like in 'required: true' you should say 'this field is required when temperature is set'
please be aware i'm using jQuery in my answer to get the value of the temperature field.. plus,
try to think it like this:
instead of saying 'this field is always required' like in 'required: true' you should say 'this field is required when temperature is set'
function isTemperatureSet(){
if( $('#temperature').val() != ""){
return true;
}
return false;
}
var rules = {
<portlet:namespace />unit: {
required: isTemperatureSet
}
};
please be aware i'm using jQuery in my answer to get the value of the temperature field.. plus,
if( $('#temperature').val() != "")
does not work for whitespaced strings, etc