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

Beginning work on client-side verification

parent 230155df
Branches
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"
...@@ -5,20 +5,24 @@ import lombok.Data; ...@@ -5,20 +5,24 @@ import lombok.Data;
@Data @Data
public class Landmarks { public class Landmarks {
private String landmarkName; private String landmarkName;
private String landmarkEmail;
private String landmarkDescription; private String landmarkDescription;
private String landmarkLocation; private String landmarkLocation;
private int trailID; private Integer trailID;
public Landmarks(){ public Landmarks(){
this.landmarkName =""; this.landmarkName ="";
this.landmarkEmail="";
this.landmarkDescription =""; this.landmarkDescription ="";
this.landmarkLocation =""; this.landmarkLocation ="";
this.trailID =0; this.trailID =0;
} }
public Landmarks(String landmarkName, String landmarkDescription, String landmarkLocation, int trailID) { public Landmarks(String landmarkName, String landmarkEmail, String landmarkDescription, String landmarkLocation, Integer trailID) {
this.landmarkName = landmarkName; this.landmarkName = landmarkName;
this.landmarkEmail = landmarkEmail;
this.landmarkDescription = landmarkDescription; this.landmarkDescription = landmarkDescription;
this.landmarkLocation = landmarkLocation; this.landmarkLocation = landmarkLocation;
this.trailID = trailID; this.trailID = trailID;
......
...@@ -11,7 +11,7 @@ public class LandmarksArray { ...@@ -11,7 +11,7 @@ public class LandmarksArray {
landmarksList = new ArrayList<>(); //ArrayList is mutable landmarksList = new ArrayList<>(); //ArrayList is mutable
landmarksList.addAll( landmarksList.addAll(
List.of( List.of(
new Landmarks("park","desc","loc",2) new Landmarks("park","asd","desc","loc",9)
) )
); );
......
...@@ -24,6 +24,7 @@ public class LandmarksController { ...@@ -24,6 +24,7 @@ public class LandmarksController {
@PostMapping("/landmarkSub") @PostMapping("/landmarkSub")
public ModelAndView landmarkSent( @ModelAttribute("landmarkData") Landmarks landmarks ) { public ModelAndView landmarkSent( @ModelAttribute("landmarkData") Landmarks landmarks ) {
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(),
......
...@@ -6,26 +6,55 @@ ...@@ -6,26 +6,55 @@
</head> </head>
<body> <body>
<main> <main>
<form action="/landmarkSub" id="landmarkSubmission" name="landmarkSubmission" method="post" th:object="${landmarkData}"> <form action="/landmarkSub" id="landmarkSubmission" name="landmarkSubmission" method="post" th:object="${landmarkData}" onsubmit="return landmarkFormValidation()">
<label>Business Name: <label>Business Name:&nbsp;
<input type="text" th:field="*{landmarkName}"> <input type="text" th:field="*{landmarkName}">
</label><br> </label><br>
<label>Contact Address:
<input type="text" th:field="*{landmarkEmail}">
</label><br>
<label>Please Describe Your Business:<br> <label>Please Describe Your Business:<br>
<textarea th:field="*{landmarkDescription}" rows="6" cols="80"></textarea> <textarea th:field="*{landmarkDescription}" rows="8" cols="60"></textarea>
</label><br> </label><br>
<label>Your town/city: <label>Your town/city:
<input type="text" th:field="*{landmarkName}"> <input type="text" th:field="*{landmarkName}">
</label><br> </label><br>
<label>Trail: <label>Trail:
<input type="text" th:field="*{trailID}">
<select th:field="*{trailID}">
<option value=0 disabled selected>Select Trail</option>
<option value=1>Trail 1</option>
<option value=2>Trail 2</option>
<option value=3>Trail 3</option>
</select>
</label><br> </label><br>
<input type="submit"> <input type="submit">
</form> </form>
</main> </main>
<script>
function landmarkFormValidation(){
console.log("sadasd");
var pass=true;
var description = (document.forms["landmarkSubmission"]["landmarkDescription"].value);
console.log(description);
var descriptionWrdCount=description.split(" ").length
if(descriptionWrdCount>5){
alert('Please keep your review to a maximum of 5 words.');
console.log("BAD!!");
pass = false;
}
return pass;
}
</script>
</body> </body>
</html> </html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment