This question already has an answer here:
How to set value to for a textarea, and get it with struts2 actions?
(1 answer)
Closed 4 years ago.
I want to disable a particular option in a radio button group with struts.
I am able to pre-select an option using below code, can I pre-disable an option too?
<s:radio label="Answer" name="yourAnswer" list="#{'1':'Yes','2':'No'}" value="2">
With iterator I got what I wanted -
<s:iterator value="genders" status="stat" var="gender">
<s:if test="%{#gender == 'male'}">
<input type="radio" name="gend" value="<s:property />" disabled="disabled">
<s:property/>
</s:if>
<s:else>
<input type="radio" name="gend" value="%{stat+'x'}">
<s:property/>
</s:else>
</s:iterator>
Related
This question already has answers here:
My regex is matching too much. How do I make it stop? [duplicate]
(5 answers)
Closed 3 years ago.
Live example:
https://regexr.com/4rblr
Source markup:
<xf:macro name="breadcrumbs" arg-breadcrumbs="!" arg-navTree="!" arg-selectedNavEntry="{{ null }}" arg-variant="">
<xf:if contentcheck="true">
<ul class="p-breadcrumbs {{ $variant ? 'p-breadcrumbs--' . $variant : '' }}"
itemscope itemtype="https://schema.org/BreadcrumbList">
<xf:contentcheck>
<xf:set var="$position" value="{{ 0 }}" />
<xf:set var="$rootBreadcrumb" value="{$navTree.{$xf.options.rootBreadcrumb}}" />
<xf:if is="$rootBreadcrumb AND $rootBreadcrumb.href != $xf.uri">
<xf:set var="$position" value="{{ $position + 1 }}" />
<xf:macro name="crumb"
arg-position="{$position}"
arg-href="{$rootBreadcrumb.href}"
arg-value="{$rootBreadcrumb.title}" />
</xf:if>
<xf:if is="$selectedNavEntry && $selectedNavEntry.href && $selectedNavEntry.href != $xf.uri && $selectedNavEntry.href != $rootBreadcrumb.href">
<xf:set var="$position" value="{{ $position + 1 }}" />
<xf:macro name="crumb"
arg-position="{$position}"
arg-href="{$selectedNavEntry.href}"
arg-value="{$selectedNavEntry.title}" />
</xf:if>
<xf:foreach loop="$breadcrumbs" value="$breadcrumb" if="$breadcrumb.href != $xf.uri">
<xf:set var="$position" value="{{ $position + 1 }}" />
<xf:macro name="crumb"
arg-position="{$position}"
arg-href="{$breadcrumb.href}"
arg-value="{$breadcrumb.value}" />
</xf:foreach>
</xf:contentcheck>
</ul>
</xf:if>
</xf:macro>
I'm trying to grab the ul.p-breadcrumbs element via regex. I can grab the ul and everything after ok using:
<p.*class.p-breadcrumbs(.*[\s]*)*
And I can select the closing tag with
<\/ul>
However putting them together doesn't work at all:
<ul.*class=.p-breadcrumbs(.*[\s]*)*<\/ul>
I followed this answer:
https://www.regextester.com/93456
But it doesn't work with multiline content. If you line break that example and enter more content it breaks the solution. Appreciate any pointers as I'm pulling hair out trying to solve the last bit!
I fixed it on my own as a regex novice by fiddling around. The first group needed a ? symbol and I don't know why, other than it somehow makes matches "lazy" and not grab too many characters.
Solution is updated with:
<ul class="p-breadcrumbs(.*?\s)*?<\/ul>
https://regexr.com/4rblr
Perhaps someone with more knowledge could demystify the ? usage for other novices?
<div draggable="true">
{{input value="default value" }}
</div>
In ember.js, as above code, when the div element has an attribute 'draggable="true"', on the webpage, the input area must need a double-click to edit in ie-11, but in chrome or firefox, it just need a click event to edit. Has anyone resolved this issue?
seems to be a bug
[IE 11] Input field of type text does not respond to mouse clicks when ancestor node has draggable=true
bad workaround:
<div style="background-color:lightgray" id="dragE" draggable="true">
<input id="inputE" type="text" />
</div>
click on the lightgray background
now the input field support single click
$('#dragE').focus(); <br>
$('#inputE').focus();<br>
was my solution
unfotunately reproducing with pluncer & co. did not work.
Or...set attribute draggable to "false", when the page goes to a production environment.
This worked for us.
In my html 5 page, I want to force the user to add in the end of his login the ".app" string.
Do you know how I can make that ?
My current code:
<input type="text" name="user_login" placeholder="firstname.app" required style="width:92%;" pattern="/.app/">
Thanks you for your help.
EDIT
I have resolved my problem with a jQuery check and a html 5 pattern
JS:
// If the user login doesn't finish by .app, we add them
if(!$('input[name=user_login]').val().match('[.]app$'))
$('input[name=user_login]').val($('input[name=user_login]').val() + '.app');
HTML5:
<input type="text" name="user_login"
placeholder="firstname.app" required style="width:92%;"
pattern=".*\.app">
There are a few differences between regex in JavaScript and in HTML attributes :
you don't have to put your regex between /, contrary to js regex literals
the start and end are implicit, so here you should add .* to match the start
You also forgot to escape the dot.
All in one, you probably want this :
<input type="text" name="user_login"
placeholder="firstname.app" required style="width:92%;"
pattern=".*\.app">
Demonstration
try this:
if($('input[name="user_login"]').val().indexOf(".app") >= 0){
//code
}
or pattern:
<input type="text" name="user_login" placeholder="firstname.app" required style="width:92%;" pattern="\w*.app">
Here is demo
You could do it by specifying the specific pattern:
<input type="text"
name="user_login"
placeholder="firstname.app"
required style="width:92%;"
pattern="[A-Za-z-0-9]+\.app">
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I'm using a simple pattern like this :
<input type="text" pattern="[a-z]{2}" required ../>
But it's never valid. It seems it didn't works.
I tested it in Firefox
Is there something to active or something like that ?
My template :
<section class="inscription">
<h1>Inscription</h1>
<form method="post" enctype="multipart/form-data">
<div class="formu-inscription">
<label for="nom"> Nom : </label> <br/><input type="text" id="nom" name="nom" value="{set_value('nom')}" pattern="[a-z]{2}" required /> <br />
{form_error('nom')}
/* others inputs */
For people using smarty template, you can do
pattern="[a-z]{literal}{2}{/literal}"
Looking at the rendered source code you posted as a comment on a now deleted answer you have
<input type="text" id="nom" name="nom" value="" pattern="[a-z]2" required />
This is not the pattern in your source that you posted in your question. It seems that you are using some unspecified templating system that is using the {} characters as field identifiers and is misinterpreting your pattern.
The result in your rendered page is the pattern [a-z]2, which will validate for a string like a2 or f2, but not a, or aa, a3 or anything longer.
Since you haven't specified what templating system you're using it's not possible to indicate how you might work around this. Possibly a pattern of [a-z]{{2}} might work.
I have below code to iterate over the list to get the radio button populate:
<s:iterator value="custData.custList" id="custNameDetail">
<li>
<s:radio name="custname" list="#{'':custName}" ></s:radio><s:property value="DescriptioMess"/>
</li>
</s:iterator>
Its working perfectly but I want to disable the first radio button. How can I iterate through list to get the specific ids and disable the first radio button?
I am getting below as the output while running the above code for all elements:
<input type="radio" name= "custname" id="custname" checked="checked" value>
I think the problem lies here. I should get the different ids for all and then only I can add disabled="disabled" for the first id.
Please let me know if you guys have come across this issue and you have any suggestions.
Thanks for all your help.
Wasn't working with JSPs for few years but isn't the syntax for variables ${variable}? Like ="${someStruct.id}"?
Posting your Java code may help to put specific answer...
What you can do is add a status variable that will give you information about the loop iteration you are on.
So you can do something like this
<s:iterator value="custData.custList" id="custNameDetail" status="loopStatus">
<li>
<s:if test="#loopStatus.first == true"> //make it disabled
<s:radio name="custname" list="#{'':custName}" ></s:radio><s:property value="DescriptioMess"/>
</s:if>
<s:else>
<s:radio name="custname" list="#{'':custName}" ></s:radio><s:property value="DescriptioMess"/>
</s:else>
</li>
</s:iterator>
See here for more information.