Disable a button with JSTL - jstl

How do I disable a submit button in JSTL if the text field is blank or empty?
<input id="name" name="name" type="text" autocomplete="off" />
<input id="namebutton" type="submit" />

Related

In my Laravel 8 Multi step form not submitting

Form not submit, eventually, it does not show any error, When I click on submit button nothing happens.
Blade file
<form id="msform" method="post" enctype="multipart/form-data" action="{{ route('agent.emp.data.add') }}">
#csrf
<fieldset>
<input type="text" name="empName" placeholder="Enter Your Name" />
<input type="text" placeholder="Date Of Birth" name="empDob" onfocus="(this.type='date')"
onblur="(this.type='text')" id="date" />
<input type="email" name="empEmail" placeholder="Enter Your Email Id" />
<input type="tel" name="empPhone" placeholder="Enter Your Phone Number" />
<input type="button" name="next" value="Next" />
</fieldset>
<fieldset>
<input type="file" name="empPhoto" accept="image/*" onchange="empphoto(this);">
<input type="button" name="previous" value="Previous" />
<input type="submit" name="submit" value="Submit" />
</fieldset>
</form>
Web Route
Route::post('empdataform', [AgentController::class, 'AgentEmpDataAdd'])->middleware('guest')->name('agent.emp.data.add');
Note: I add the AgentController In Route Top
Agent Controller
class AgentController extends Controller
{
public function AgentEmpDataAdd(Request $request){
return $request->all();
}
}
Please Help me in this mater.

Transfer data in Thymeleaf

I have two input value like this
<input type="text" th:field="*{itemID}"placeholder="Bidding id" class="form-
control" required />
------------
<input type="hidden" th:field="*{item.id}" />
okay so how can i put the value of item.id field into itemID ?. I tried like below but it didn't work
<input type="hidden" th:field="*{itemID}" th:value="*{item.id}"
placeholder="Bidding id" class="form-control" required />
update
i tried to make it like this, but it still not work
<input type="hidden" th:name="*{itemID}" th:value="1"
placeholder="Bidding id" class="form-control" required />
Try this :
<input type="hidden" th:field="*{itemID}" th:value="${item.id}" placeholder="Bidding id" class="form-control" required />
replace the * by $ in th:value attribute

Grails ajax radio buttons

I'm looking to have two radio groups within a single form. When you select a radio button (product type) form the first group, I'd like to update the second group (quantity) and adjust the price using Ajax. Does Grails offer an Ajax radio solution?
<form>
<div>
Product Type
<input type="radio" name="q1" value="1"/>
<input type="radio" name="q1" value="2"/>
<input type="radio" name="q1" value="3"/>
</div>
<div>
Quantity
<input type="radio" name="q2" value="1"/> ${price}
<input type="radio" name="q2" value="2"/> ${price}
<input type="radio" name="q2" value="3"/> ${price}
<input type="radio" name="q2" value="4"/> ${price}
<input type="radio" name="q2" value="5"/> ${price}
</div>
<input type="submit" name="submit" id="submit" />
</form>
Take a look at the g:formRemote tag:
http://grails.github.io/grails-doc/2.1.0/ref/Tags/formRemote.html

Validation of prefilled contact form fields in Magento fails

My Magento contact form has the field names prefilled, not labelled.
<input name="name" id="name" value="Name" class="required-entry input-text" type="text" />
Since the field is prefilled, the validation "required-entry" fails.
Is there a not-so-dirty way to get the validation working with prefilled values?
just try to use. Placeholder to make prefilled text
<form action="demo_form.asp">
<input type="text" name="fname" placeholder="First name"><br>
<input type="text" name="lname" placeholder="Last name"><br>
<input type="submit" value="Submit">
</form>
that would sure help you.

How can I validate that a radio button was selected using cfform built-in validation?

Say I have a simple cfform that looks like this:
<cfform id="fruitForm" method="post" action="">
<cfinput type="radio" name="fruit" id="fruit_apple" value="Apple" /><label for="fruit_apple">Apple</label><br />
<cfinput type="radio" name="fruit" id="fruit_orange" value="Orange" /><label for="fruit_orange">Orange</label><br />
<cfinput type="radio" name="fruit" id="fruit_pear" value="Pear" /><label for="fruit_pear">Pear</label><br />
<cfinput type="submit" name="submitFruit" id="submitFruit" value="Submit" />
</cfform>
How can I use the built-in cfform validation to ensure that at least one radio button in this group is selected? I've tried adding a validate="required" to each of the radio buttons but it doesn't work. Is there any simple way to "require" one of the buttons to be selected using cfform validation?
Do yourself a favor and don't use cfform for validation. Write your own server and client side validation, but according to the cfinput documentation if you add a required="true" attribute to each radio button ColdFusion will do the client side validation for you.
Note: The user can bypass this validation and still submit a form without checking a radio button. You need to have server side validation as well.
<cfform id="fruitForm" method="post" action="">
<cfinput type="radio" name="fruit" id="fruit_apple" value="Apple" required="true" /><label for="fruit_apple">Apple</label><br />
<cfinput type="radio" name="fruit" id="fruit_orange" value="Orange" required="true" /><label for="fruit_orange">Orange</label><br />
<cfinput type="radio" name="fruit" id="fruit_pear" value="Pear" required="true" /><label for="fruit_pear">Pear</label><br />
<cfinput type="submit" name="submitFruit" id="submitFruit" value="Submit" />
</cfform>
This works for me:
<cfform action="abc.cfm" method="post">
<cfinput type="radio" required="yes" message="pick something" name="x" value="1">radio 1
<cfinput type="radio" required="yes" message="pick something" name="x" value="">radio 2
<input type="submit" />
</cfform>
In fact, you don't even need the message attribute. It will still validate.

Resources