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
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"
......@@ -5,20 +5,24 @@ import lombok.Data;
@Data
public class Landmarks {
private String landmarkName;
private String landmarkEmail;
private String landmarkDescription;
private String landmarkLocation;
private int trailID;
private Integer trailID;
public Landmarks(){
this.landmarkName ="";
this.landmarkEmail="";
this.landmarkDescription ="";
this.landmarkLocation ="";
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.landmarkEmail = landmarkEmail;
this.landmarkDescription = landmarkDescription;
this.landmarkLocation = landmarkLocation;
this.trailID = trailID;
......
......@@ -11,7 +11,7 @@ public class LandmarksArray {
landmarksList = new ArrayList<>(); //ArrayList is mutable
landmarksList.addAll(
List.of(
new Landmarks("park","desc","loc",2)
new Landmarks("park","asd","desc","loc",9)
)
);
......
......@@ -24,6 +24,7 @@ public class LandmarksController {
@PostMapping("/landmarkSub")
public ModelAndView landmarkSent( @ModelAttribute("landmarkData") Landmarks landmarks ) {
System.out.println(landmarks);
// LandmarksArray userArray = LandmarksArray.getInstance();
// Landmarks newUserSubmission = new Landmarks(landmarkData.getFormUsername(),userSubmission.getFormEmail(),
......
......@@ -6,26 +6,55 @@
</head>
<body>
<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}">
</label><br>
<label>Contact Address:
<input type="text" th:field="*{landmarkEmail}">
</label><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>Your town/city:
<input type="text" th:field="*{landmarkName}">
</label><br>
<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>
<input type="submit">
</form>
</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>
</html>
\ No newline at end of file
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