on Bean Class
@Table(name="signup",uniqueConstraints = {@UniqueConstraint(name="UniqueNumberAndStatus" ,columnNames = {"email"})})
public class SignUpUser {
@Id
@GeneratedValue(strategy = GenerationType.AUTO )
@Column(name = "user_id")
private long id;
@NotBlank(message = "(Name should be not blank ..!!)")
private String name;
@NotBlank(message = "(mobile should be not blank ..!!)")
private String mobile;
@NotBlank(message = "(Email should be not blank ..!!)")
@Pattern(regexp = "^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+$",message = "(email format example : abc@example.com)")
private String email;
@NotBlank(message = "(Password Number should be not blank ..!!)")
private String password;
@NotBlank(message = "(mobile should be not blank ..!!)")
private String address;
on controller
@PostMapping("/HolidayName")
public String PostPackageName(@Valid @ModelAttribute com.entity.PackageName packageName,BindingResult br,Model m){
List<com.entity.PackageName> packageNames=packageNameRepo.findAll();
m.addAttribute("AllHolidayPackage", packageNames);
try {
if(br.hasErrors()) {
return "Admin/PackageName";
}
packageNameRepo.save(packageName);
return "redirect:/admin/PackageName";
} catch (Exception e) {
m.addAttribute("mess", "This Package Name address already exist");
return "Admin/PackageName";
}
}
on html
<form th:action="@{/NowCreateAccount}" method="post" th:object="${signUpUser}">
<div class="signup_box"></div>
<div class="signup_inputBox">
<span id="signup_inputBox_te" > <b> Full Name *</b> :</span>
<span style="color:red;margin-bottom:-5%;background-color:#ff4d4d;color:white;padding:2px 2px;border-radius:5px;font-size:11px" th:each="e:${#fields.errors('name')}" th:text="${e}"></span>
<p style="text-align:center;"> <br> <input class="signup_content_input" type="text" name="name" placeholder="enter your name *" th:value="${signUpUser.name}"> </p>
</div>
<div class="signup_inputBox">
<span id="signup_inputBox_te"> <b> Mobile Number *</b>: </span>
<span style="color:red;margin-bottom:-5%;background-color:#ff4d4d;color:white;padding:2px 5px;border-radius:5px;font-size:11px" th:each="e:${#fields.errors('mobile')}" th:text="${e}"></span>
<p style="text-align:center;"> <br> <input class="signup_content_input" type="text" name="mobile" placeholder="enter your mobile number *" th:value="${signUpUser.mobile}"> </p>
</div>
<div class="signup_inputBox">
<span id="signup_inputBox_te"> <b> Email Address *</b>: </span>
<span style="color:red;margin-bottom:-5%;background-color:#ff4d4d;color:white;padding:2px 5px;border-radius:5px;font-size:11px" th:each="e:${#fields.errors('email')}" th:text="${e}"></span>
<p style="text-align:center;"> <br> <input class="signup_content_input" type="text" name="email" placeholder="enter your Email *" th:value="${signUpUser.email}"> </p>
</div>
<div class="signup_inputBox">
<span id="signup_inputBox_te"> <b> Password *</b>: </span>
<span style="color:red;margin-bottom:-5%;background-color:#ff4d4d;color:white;padding:2px 5px;border-radius:5px;font-size:11px" th:each="e:${#fields.errors('password')}" th:text="${e}"></span>
<p style="text-align:center;"> <br> <input class="signup_content_input" id="psw" type="password" name="password" placeholder="enter your password *" th:field="${signUpUser.password}" pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}" title="Must contain at least one number and one uppercase and lowercase letter, and at least 8 or more characters" required> </p>
</div>
<div class="signup_inputBox">
<p style="text-align:center;"> <br> <input type="checkbox" onclick="pswFun()"> Do you want show password, what you entered !!</p>
</div>
<script type="text/javascript">
function pswFun() {
var x=document.getElementById("psw");
if(x.type=="password"){
x.type = "text";
} else {
x.type = "password";
}
}
</script>
<div class="signup_inputBox">
<span id="signup_inputBox_te"> <b> Address *</b>: </span>
<span style="color:red;margin-bottom:-5%;background-color:#ff4d4d;color:white;padding:2px 5px;border-radius:5px;font-size:11px" th:each="e:${#fields.errors('address')}" th:text="${e}"></span>
<p style="text-align:center;"> <br> <textarea style="height:60px" class="signup_content_input" name="address" placeholder="enter your Address *" th:value="${signUpUser.address}"></textarea> </p>
</div>
<div class="signup_inputBox">
<p style="text-align:center;"> <input type="checkbox" name="tc" required> * Accept Term & Conditions <a style="text-decoration:underline;color:#004d66;font-weight:bold" href="">Read here</a> </p>
</div>
<div class="signup_inputBox">
<p style="text-align:center;"> <input class="signup_content_button" type="submit" value="Enter to create Account"> </p>
</div>
</form>
Comments
Post a Comment