How can I force Visualforce to include empty attributes which I have specified?
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
4
down vote
favorite
During my adventures trying to get a <select required="required">
to actually be required, I discovered:
If a select element has a required attribute specified, does not have a multiple attribute specified, and has a display size of 1; and if the value of the first option element in the select element's list of options (if any) is the empty string, and that option element's parent node is the select element (and not an optgroup element), then that option is the select element's placeholder label option.
So I changed my markup to mirror that:
<select required="required" ...>
<option value="">--</option>
...
</select>
But unfortunatley it rendered as:
<select required="required" ...>
<option>--</option>
...
</select>
And because value=""
was stripped out, it no longer meets the specification for <select required="required">
, and the form can be submitted with no value selected.
How can I get the value=""
attribute specification to stick?
visualforce html html5
add a comment |Â
up vote
4
down vote
favorite
During my adventures trying to get a <select required="required">
to actually be required, I discovered:
If a select element has a required attribute specified, does not have a multiple attribute specified, and has a display size of 1; and if the value of the first option element in the select element's list of options (if any) is the empty string, and that option element's parent node is the select element (and not an optgroup element), then that option is the select element's placeholder label option.
So I changed my markup to mirror that:
<select required="required" ...>
<option value="">--</option>
...
</select>
But unfortunatley it rendered as:
<select required="required" ...>
<option>--</option>
...
</select>
And because value=""
was stripped out, it no longer meets the specification for <select required="required">
, and the form can be submitted with no value selected.
How can I get the value=""
attribute specification to stick?
visualforce html html5
add a comment |Â
up vote
4
down vote
favorite
up vote
4
down vote
favorite
During my adventures trying to get a <select required="required">
to actually be required, I discovered:
If a select element has a required attribute specified, does not have a multiple attribute specified, and has a display size of 1; and if the value of the first option element in the select element's list of options (if any) is the empty string, and that option element's parent node is the select element (and not an optgroup element), then that option is the select element's placeholder label option.
So I changed my markup to mirror that:
<select required="required" ...>
<option value="">--</option>
...
</select>
But unfortunatley it rendered as:
<select required="required" ...>
<option>--</option>
...
</select>
And because value=""
was stripped out, it no longer meets the specification for <select required="required">
, and the form can be submitted with no value selected.
How can I get the value=""
attribute specification to stick?
visualforce html html5
During my adventures trying to get a <select required="required">
to actually be required, I discovered:
If a select element has a required attribute specified, does not have a multiple attribute specified, and has a display size of 1; and if the value of the first option element in the select element's list of options (if any) is the empty string, and that option element's parent node is the select element (and not an optgroup element), then that option is the select element's placeholder label option.
So I changed my markup to mirror that:
<select required="required" ...>
<option value="">--</option>
...
</select>
But unfortunatley it rendered as:
<select required="required" ...>
<option>--</option>
...
</select>
And because value=""
was stripped out, it no longer meets the specification for <select required="required">
, and the form can be submitted with no value selected.
How can I get the value=""
attribute specification to stick?
visualforce html html5
visualforce html html5
asked 1 hour ago
Adrian Larsonâ¦
101k19108228
101k19108228
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
4
down vote
Here is another way to do it w/o javascript:
Set the value to a VisualForce function that evaluates to nothing:
<apex:page standardController="Contact" >
<apex:form>
<select required="required">
<option value="!IF(1=1,'','')">--</option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</select>
<apex:commandButton value="Test Submit" action="!save" />
</apex:form>
It will send the value attribute to the browser:
The browser will require it now:
I preferIF(true,...)
toIF(1=1,...)
. Regardless, it is much better to avoid javascript than what I came to on my own.
â Adrian Larsonâ¦
20 mins ago
add a comment |Â
up vote
0
down vote
It's ugly, but below is the workaround I found. I would be happy to find one which does not require Javascript.
Since I already had a page load listener, I simply appended to it:
(function (w)
"use strict";
w.addEventListener("load", function ()
.forEach.call(
document.querySelectorAll("option:not([value])"),
function (element) element.value = '';
);
)(window);
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
Here is another way to do it w/o javascript:
Set the value to a VisualForce function that evaluates to nothing:
<apex:page standardController="Contact" >
<apex:form>
<select required="required">
<option value="!IF(1=1,'','')">--</option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</select>
<apex:commandButton value="Test Submit" action="!save" />
</apex:form>
It will send the value attribute to the browser:
The browser will require it now:
I preferIF(true,...)
toIF(1=1,...)
. Regardless, it is much better to avoid javascript than what I came to on my own.
â Adrian Larsonâ¦
20 mins ago
add a comment |Â
up vote
4
down vote
Here is another way to do it w/o javascript:
Set the value to a VisualForce function that evaluates to nothing:
<apex:page standardController="Contact" >
<apex:form>
<select required="required">
<option value="!IF(1=1,'','')">--</option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</select>
<apex:commandButton value="Test Submit" action="!save" />
</apex:form>
It will send the value attribute to the browser:
The browser will require it now:
I preferIF(true,...)
toIF(1=1,...)
. Regardless, it is much better to avoid javascript than what I came to on my own.
â Adrian Larsonâ¦
20 mins ago
add a comment |Â
up vote
4
down vote
up vote
4
down vote
Here is another way to do it w/o javascript:
Set the value to a VisualForce function that evaluates to nothing:
<apex:page standardController="Contact" >
<apex:form>
<select required="required">
<option value="!IF(1=1,'','')">--</option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</select>
<apex:commandButton value="Test Submit" action="!save" />
</apex:form>
It will send the value attribute to the browser:
The browser will require it now:
Here is another way to do it w/o javascript:
Set the value to a VisualForce function that evaluates to nothing:
<apex:page standardController="Contact" >
<apex:form>
<select required="required">
<option value="!IF(1=1,'','')">--</option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</select>
<apex:commandButton value="Test Submit" action="!save" />
</apex:form>
It will send the value attribute to the browser:
The browser will require it now:
answered 26 mins ago
HungryBeagle
39518
39518
I preferIF(true,...)
toIF(1=1,...)
. Regardless, it is much better to avoid javascript than what I came to on my own.
â Adrian Larsonâ¦
20 mins ago
add a comment |Â
I preferIF(true,...)
toIF(1=1,...)
. Regardless, it is much better to avoid javascript than what I came to on my own.
â Adrian Larsonâ¦
20 mins ago
I prefer
IF(true,...)
to IF(1=1,...)
. Regardless, it is much better to avoid javascript than what I came to on my own.â Adrian Larsonâ¦
20 mins ago
I prefer
IF(true,...)
to IF(1=1,...)
. Regardless, it is much better to avoid javascript than what I came to on my own.â Adrian Larsonâ¦
20 mins ago
add a comment |Â
up vote
0
down vote
It's ugly, but below is the workaround I found. I would be happy to find one which does not require Javascript.
Since I already had a page load listener, I simply appended to it:
(function (w)
"use strict";
w.addEventListener("load", function ()
.forEach.call(
document.querySelectorAll("option:not([value])"),
function (element) element.value = '';
);
)(window);
add a comment |Â
up vote
0
down vote
It's ugly, but below is the workaround I found. I would be happy to find one which does not require Javascript.
Since I already had a page load listener, I simply appended to it:
(function (w)
"use strict";
w.addEventListener("load", function ()
.forEach.call(
document.querySelectorAll("option:not([value])"),
function (element) element.value = '';
);
)(window);
add a comment |Â
up vote
0
down vote
up vote
0
down vote
It's ugly, but below is the workaround I found. I would be happy to find one which does not require Javascript.
Since I already had a page load listener, I simply appended to it:
(function (w)
"use strict";
w.addEventListener("load", function ()
.forEach.call(
document.querySelectorAll("option:not([value])"),
function (element) element.value = '';
);
)(window);
It's ugly, but below is the workaround I found. I would be happy to find one which does not require Javascript.
Since I already had a page load listener, I simply appended to it:
(function (w)
"use strict";
w.addEventListener("load", function ()
.forEach.call(
document.querySelectorAll("option:not([value])"),
function (element) element.value = '';
);
)(window);
answered 1 hour ago
Adrian Larsonâ¦
101k19108228
101k19108228
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f235668%2fhow-can-i-force-visualforce-to-include-empty-attributes-which-i-have-specified%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password