I have implemented, mailing feature through which a confirmation token is send to the user and on clicking the url provided, a page opens that fills the email id of the user to which the email is sent.
Then they can reset, however when i am trying to submit the form with the new password. It is not passing the value to the function i have provided.
#PostMapping("/resetUserPassword")
public String accountPasswordReset(#Valid #ModelAttribute("updateUserPassword") ResetPassword user, BindingResult theBindingResult, Model theModel){
//this line outputs null value
System.out.println("accountPasswordReset: email="+user.getEmail());
if(user.getEmail()!=null) {
User tokenUser = userService.findByEmailIdIgnoreCase(user.getEmail());
tokenUser.setPassword(passwordEncoder.encode(user.getPassword()));
userService.save(tokenUser);
return "successPasswordReset";
}else {
return "error";
}
}
<form:form action="${pageContext.request.contextPath}/register/resetUserPassword" modelAttribute="updateUserPassword" class="form-horizontal" method="POST">
<!-- Email -->
<div class="form-group">
<label for="emailId">Email (*)</label>
<form:input path="email" id="emailId" placeholder="email (*)"
class="form-control" disabled="true" readonly="true" />
<form:errors path="email" cssClass="error" />
</div>
<!-- Password -->
<div class="form-group">
<label for="password">Password (*)</label>
<form:password path="password" id="password"
placeholder="password (*)" class="form-control" />
<form:errors path="password" cssClass="error" />
</div>
<!-- Reset Button -->
<div style="margin-top: 10px" class="form-group">
<div class="col-sm-6 controls">
<button type="submit" class="btn btn-primary">Reset</button>
</div>
</div>
</form:form>
I was missing smallest thing, in this line i just removed disabled="true" and it works
<form:input path="email" id="emailId" placeholder="email (*)" class="form-control" disabled="true" readonly="true" />
to
<form:input path="email" id="emailId" placeholder="email (*)" class="form-control" readonly="true" />
Related
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.
I am trying to use autocomplete="false" in my registration form for remove autocomplete the field (UserName and Password) but it not work.
I read the attribute autocomplete from this site https://docs.spring.io/spring/docs/4.0.x/spring-framework-reference/html/spring-form.tld.html#spring-form.tld.input
This is my code and UI snapshot.
[![<form:form method="POST" action="${contextPath}/register" modelAttribute="registerForm"
class="form-signin" >
<input autocomplete="false" name="hidden" type="text" style="display:none;">
<spring:bind path="username">
<label class="label">Username</label>
<div class="form-group ${status.error ? 'has-error' : ''}">
<form:input type="text" path="username" class="form-control"
autofocus="true" autocomplete="false" />
<form:errors path="username" cssStyle="color:#ff0000;"></form:errors>
</div>
</spring:bind>
<spring:bind path="email">
<label class="label">Email</label>
<div class="form-group ${status.error ? 'has-error' : ''}">
<form:input id="email" type="email" autocomplete="1" path="email"
class="form-control" name="email"
pattern="\[a-z0-9._%+-\]+#\[a-z0-9.-\]+\.\[a-z\]{2,3}$"/>
<form:errors path="email" cssStyle="color: #ff0000;"></form:errors>
</div>
</spring:bind>
<spring:bind path="password">
<label class="label">Password</label>
<div class="form-group ${status.error ? 'has-error' : ''}">
<form:input type="password" path="password" class="form-control" autocomplete="false" id="password"></form:input>
<form:errors path="password" cssStyle="color: #ff0000;"></form:errors>
</div>
</spring:bind>
<button class="btn btn-primary auth-btn" type="submit">Submit</button>
</form:form>][1]][1]
you can use autocomplete="off"
it's supposed to solve your problems
I have created an form for submission and written a controller method to handle it in spring MVC. But the request is not reaching the controller method.Please let me know what mistake i'm making in writing the controller/form method.
Below is my code snippet which is self explanatory.
Controller method:
#RequestMapping(value="/users/login/projectUpdate",method=RequestMethod.POST)
public String updateProjectStatus( User user,Model model,Authentication
authentication,HttpServletRequest request,final RedirectAttributes
redirectAttributes) {
logger.debug("Update Project Status Data()");
String projectname=request.getParameter("projectName");
String projectStatus=request.getParameter("projectStatus");
String projectStatusDate=request.getParameter("projectStatusDate");
userService.updateProject(projectStatus,projectStatusDate,projectname);
return "users/updateProject";
}
JSP form:
<spring:url value="/users/login/projectUpdate" var="updateProjectUrl" />
<form:form method="post" modelAttribute="updateProjectForm"
action="${updateProjectUrl}" id="ProjectForm">
<label class="col-sm-2 control-label">Projects</label>
<div class="col-sm-9">
<form:select path="project" multiple="false" class="form-control" id="project1">
<form:option label="--Select--" value=""/>
<form:options items="${project}" />
</form:select>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Project Description</label>
<div class="col-sm-9">
<form:input path="projectDescription" type="text" class="form-control" id="projectDescription1" placeholder="Project Description" readonly="true"/>
</div>
</div>
<div class="form-group ${status.error ? 'has-error' : ''}">
<label class="col-sm-2 control-label">Project Start Date</label>
<div class="col-sm-9">
<form:input path="projectStartDate" type="text" class="form-control" id="projectStartDate1" placeholder="Project Start Date" readonly="true" />
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Current Status</label>
<div class="col-sm-9">
<form:input path="projectCurrentStatus" type="text" class="form-control" id="projectCurrentStatus" placeholder="Project Status" readonly="true"/>
</div>
</div>
<div class="form-group ${status.error ? 'has-error' : ''}">
<label class="col-sm-2 control-label">Current Status Date</label>
<div class="col-sm-9">
<form:input path="projectCurrentStatusDate" type="text" class="form-control " id="projectCurrentStatusDate" placeholder="Project Current Status Date" readonly="true"/>
</div>
</div>
<label class="col-sm-2 control-label">New Status</label>
<div class="col-sm-9">
<form:select path="projectStatus" multiple="false" class="form-control" id="projectStatus1" >
<form:option label="--Select--" value=""/>
<form:options items="${projectstatus}" />
</form:select>
</div>
<label class="col-sm-2 control-label">New Status Date</label>
<div class="col-sm-9">
<form:input path="projectStatusDate" type="date" class="form-control " id="projectStatusDate1" placeholder="Project Status Date" data-validation="date" data-validation-format="yyyy-mm-dd" />
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Project Team Members</label>
<div class="col-sm-9">
<form:input path="projectTeam" type="text" class="form-control " id="projectTeam1" placeholder="Project Team members" />
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-5 col-sm-7">
<button type="submit" class="btn btn-success">Update</button>
</div>
</div>
Please try using BindingResult like below :
public String updateProjectStatus( User user,BindingResult bindingResult,Model model,Authentication authentication,HttpServletRequest request,final RedirectAttributes redirectAttributes){
if (bindingResult.hasErrors()) {
//check your errors here
}
}
and make sure all the fields which you are passing from JSP should be present in your User class.
I'm trying to get Angular form validation working in ie8. Here is my code:
<form id="contact-form" name="cform" target="_blank" >
<div class="left">
<div>
<div class="group">
<label for="firstname">First Name <span class="asterisk">*</span></label><br />
<input type="text" name="firstname" id="firstname" data-ng-model="firstname" required />
<span class="error" data-ng-show="cform.input.$error.required">Required!</span>
</div>
<div class="group">
<label for="lastname">Last Name <span class="asterisk">*</span></label><br />
<input type="text" name="lastname" id="lastname" data-ng-model="lastname" required />
<span class="error" data-ng-show="cform.input.$error.required">Required!</span>
</div>
</div>
<div>
<div class="group">
<label for="email">Email Address <span class="asterisk">*</span></label><br />
<input type="email" id="email" name="email" data-ng-model="email" required />
<span class="error" data-ng-show="cform.email.$error.email">Required!</span>
</div>
</div>
<div>
<div class="group">
<label for="phone">Primary Phone Number <span class="asterisk">*</span></label><br />
<input type="text" name="phone" id="phone" data-ng-model="phone" required />
<span class="error" data-ng-show="cform.input.$error.required">Required!</span>
</div>
<div class="group">
<label for="-secondary-phone">Secondary Phone Number</label><br />
<input type="text" name="secondary-phone" id="secondary-phone" />
</div>
</div>
</div>
<div class="right">
<div class="group">
<label for="message">Your Message</label><br />
<textarea id="message"></textarea>
</div><br />
<input type="submit" value="SEND MESSAGE" class="button">
</div>
</form>
This works in Firefox and Chrome, but in IE8 no validation errors are triggered. Anyone know what the issue might be?
Thanks.
UPDATE: This seems to be a problem in all versions of IE. {{cform.input.$error}} and {{cform.input}} don't show output in any browser.
<div class="group">
<label for="firstname">First Name <span class="asterisk">*</span></label><br />
<input type="text" name="firstname" id="firstname" data-ng-model="firstname" ng-required="true" />
<span class="error" data-ng-show="cform.firstname.$error.required && cform.firstname.$dirty">Required!</span>
</div>
Ie 8 does not support html 5 ,Angular is using html 5 , Do the work around to get angular working on IE and then use the pattern because you cant use the html 5 element
i want to use the hidden form value "virtuemart_product_price" a administrator\components\com_virtuemart\helpers\calculationh.php
this form is added in components\com_virtuemart\views\cart\tmpl\default.php ..
<form method="post" class="product js-recalculate" action="/ecomm/index.php/component/virtuemart/">
<div class="addtocart-bar">
<!-- <label for="quantity229" class="quantity_box">Quantity: </label> -->
<span class="quantity-box">
<input type="hidden" class="quantity-input js-recalculate" name="quantity[]" value="1"/>
</span>
<span class="addtocart-button">
<input type="submit" name="addtocart" class="addtocart-button" value="Pick free" title="Pick free" /> </span>
<div class="clear"></div>
</div>
<input type="hidden" name="virtuemart_product_price" value="5" />
<input type="hidden" class="pname" value="Custom Item"/>
<input type="hidden" name="option" value="com_virtuemart"/>
<input type="hidden" name="view" value="cart"/>
<noscript><input type="hidden" name="task" value="add"/></noscript>
<input type="hidden" name="virtuemart_product_id[]" value="<?php echo virtuemart_product_id;?>"/>
</form>
i tried to get but i can't find a solution.