Skip to content
Snippets Groups Projects
Commit e2da4480 authored by Rhys Evans's avatar Rhys Evans
Browse files

Styling for the form

parent e9962cae
No related branches found
No related tags found
1 merge request!13Resolve "As a user I want to be able submit a form about a specific landmark to add to the trail"
This commit is part of merge request !13. Comments created here will be created in the context of that merge request.
...@@ -25,13 +25,14 @@ public class LandmarksController { ...@@ -25,13 +25,14 @@ public class LandmarksController {
@PostMapping("/landmarkSub") @PostMapping("/landmarkSub")
public ModelAndView landmarkSent(@Valid @ModelAttribute("landmarkData") Landmarks landmarks, BindingResult bindingResult, Model model ) { public ModelAndView landmarkSent(@Valid @ModelAttribute("landmarkData") Landmarks landmarks, BindingResult bindingResult, Model model ) {
System.out.println(landmarks);
if (bindingResult.hasErrors()) { if (bindingResult.hasErrors()) {
ModelAndView modelAndView = new ModelAndView("Landmarks/LandmarkFormTh.html", model.asMap()); ModelAndView modelAndView = new ModelAndView("Landmarks/LandmarkFormTh.html", model.asMap());
return modelAndView; return modelAndView;
} else{ } else{
System.out.println(landmarks);
// LandmarksArray userArray = LandmarksArray.getInstance(); // LandmarksArray userArray = LandmarksArray.getInstance();
// Landmarks newUserSubmission = new Landmarks(landmarkData.getFormUsername(),userSubmission.getFormEmail(), // Landmarks newUserSubmission = new Landmarks(landmarkData.getFormUsername(),userSubmission.getFormEmail(),
......
...@@ -30,20 +30,21 @@ ...@@ -30,20 +30,21 @@
<body> <body>
<header th:insert="~{/towns/Templating.html :: header}"></header> <header th:insert="~{/towns/Templating.html :: header}"></header>
<main> <main>
<hr style="height:40px; visibility:hidden;" />
<form action="/landmarkSub" id="landmarkSubmission" name="landmarkSubmission" method="post" th:object="${landmarkData}" onsubmit="return landmarkFormValidation()"> <form action="/landmarkSub" id="landmarkSubmission" name="landmarkSubmission" method="post" th:object="${landmarkData}" onsubmit="return landmarkFormValidation()">
<br> <br>
<label>Business Name: <label>Business Name:
<input type="text" th:field="*{landmarkName}"> <input type="text" th:field="*{landmarkName}">
</label><br><br> </label><br>
<div th:errors="*{landmarkName}" th:if="${#fields.hasErrors('landmarkName')}">ErrorLandmarkName</div> <div th:errors="*{landmarkName}" th:if="${#fields.hasErrors('landmarkName')}">ErrorLandmarkName</div>
<label>Contact Address: <br><label>Contact Address:
<input type="text" th:field="*{landmarkEmail}"> <input type="text" th:field="*{landmarkEmail}">
</label><br><br> </label><br>
<div th:errors="*{landmarkEmail}" th:if="${#fields.hasErrors('landmarkEmail')}">ErrorEmail</div> <div th:errors="*{landmarkEmail}" th:if="${#fields.hasErrors('landmarkEmail')}">ErrorEmail</div>
<label>Please Describe Your Business:<br> <br><label>Please Describe Your Business:<br>
<textarea th:field="*{landmarkDescription}" rows="8" cols="60"></textarea> <textarea th:field="*{landmarkDescription}" rows="8" cols="60" placeholder="Max 200 words please..."></textarea>
</label><br><br> </label><br><br>
<label>Your Location: <label>Your Location:
<!-- <input type="text" th:field="*{landmarkLocation}">--> <!-- <input type="text" th:field="*{landmarkLocation}">-->
...@@ -57,11 +58,11 @@ ...@@ -57,11 +58,11 @@
<label>Trail: <label>Trail:
<select th:field="*{trailID}"> <select th:field="*{trailID}">
<option value=0 disabled selected>Select Trail</option> <option value=0 disabled selected>Select Trail</option>
<option value=1>(Caerphilly) Castle Trail</option> <option value=0101>(Caerphilly) Castle Trail</option>
<option value=2>(Caerphilly) Pub Trail</option> <option value=0102>(Caerphilly) Pub Trail</option>
<option value=3>(Caerphilly) Heritage Trail</option> <option value=0103>(Caerphilly) Heritage Trail</option>
<option value=4>(Caerphilly) Heritage Trail</option> <option value=0201>(Risca) Heritage and Culture Trail</option>
<option value=5>(Caerphilly) Heritage Trail</option> <option value=0301>(Penarth) Esplanade Trail</option>
</select> </select>
</label><br><br> </label><br><br>
...@@ -71,6 +72,7 @@ ...@@ -71,6 +72,7 @@
<hr style="height:0px; visibility:hidden;" /> <hr style="height:0px; visibility:hidden;" />
</form> </form>
<hr style="height:40px; visibility:hidden;" />
</main> </main>
<script> <script>
...@@ -80,7 +82,6 @@ ...@@ -80,7 +82,6 @@
function landmarkFormValidation(){ function landmarkFormValidation(){
// let element=document.getElementById("landmarkSubmission");
var pass=true; var pass=true;
var trail = document.forms["landmarkSubmission"]["trailID"].value var trail = document.forms["landmarkSubmission"]["trailID"].value
var location = document.forms["landmarkSubmission"]["landmarkLocation"].value var location = document.forms["landmarkSubmission"]["landmarkLocation"].value
...@@ -94,22 +95,18 @@ ...@@ -94,22 +95,18 @@
if (trail==0){ if (trail==0){
alert('Invalid trail selected. \nPlease select the trail you wish to join.'); alert('Invalid trail selected. \nPlease select the trail you wish to join.');
pass = false; pass = false;
} else{
trail.innerHTML = option.text;
alert(trail.innerHTML)
alert('a')
} }
if (location==0){ if (location==""){
alert('Invalid location selected. \nPlease select the location you wish to join.'); alert('Invalid location selected. \nPlease select the location you wish to join.');
pass = false; pass = false;
} } if ( (location=="Caerphilly" & (parseInt(trail/100)!==1)) ||
if (trail==5){ (location=="Risca" & (parseInt(trail/100)!==2)) ||
(location=="Penarth" & (parseInt(trail/100)!==3)) ){
trail.value=29; alert('Trail unavailable in your current location. \nPlease choose an available trail');
pass = false;
} }
return pass; return pass;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment