Skip to content
This repository has been archived by the owner on Apr 23, 2024. It is now read-only.

Commit

Permalink
fix: separate js from php
Browse files Browse the repository at this point in the history
  • Loading branch information
na-teag committed Apr 17, 2024
1 parent 9e45359 commit ec59536
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 29 deletions.
21 changes: 21 additions & 0 deletions public/js/contact.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
function updateCounterSubject() {
let textarea = document.getElementsByName("subject")[0];
let charCount = document.getElementById("counterSubject");
let maxChars = parseInt(textarea.getAttribute("maxlength"));

if (textarea.value.length > maxChars) {
textarea.value = textarea.value.substring(0, maxChars);
}
charCount.textContent = textarea.value.length + "/" + maxChars;
}

function updateCounterContent() {
let textarea = document.getElementsByName("content")[0];
let charCount = document.getElementById("counterContent");
let maxChars = parseInt(textarea.getAttribute("maxlength"));

if (textarea.value.length > maxChars) {
textarea.value = textarea.value.substring(0, maxChars);
}
charCount.textContent = textarea.value.length + "/" + maxChars;
}
33 changes: 4 additions & 29 deletions resources/views/contact.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,48 +41,23 @@
<option value="{{$job->id}}" @if(Auth::user() != null && Auth::user()->job_id == $job->id) selected @endif>{{$job->name}} </option>
@endforeach
</select>
</div>
<hr/>
</div>
<hr/>
<div class="inputsub">
<label for="subject">Objet: </label>
<label for="subject">Objet: </label>
<input type="text" id="subject" name="subject" maxlength="100" oninput="updateCounterSubject()" required/>
<div id="counterSubject">0/100</div>
</div>
<div class="inputsub">
<label for="content">Message: </label>
<textarea name="content" maxlength="1000" oninput="updateCounterContent()" required></textarea>
<div id="counterContent">0/1000</div>
</div>
<div id="counterContent">0/1000</div>
<div class="button">
<input type="submit" value="Envoyer"/>
</div>
</form>
</div>
</div>
<script type="text/javascript"> <!-- unable to load js in file.js ; error MIME type invalid -->
function updateCounterSubject() {
let textarea = document.getElementsByName("subject")[0];
let charCount = document.getElementById("counterSubject");
let maxChars = parseInt(textarea.getAttribute("maxlength"));
if (textarea.value.length > maxChars) {
textarea.value = textarea.value.substring(0, maxChars);
}
charCount.textContent = textarea.value.length + "/" + maxChars;
}
function updateCounterContent() {
let textarea = document.getElementsByName("content")[0];
let charCount = document.getElementById("counterContent");
let maxChars = parseInt(textarea.getAttribute("maxlength"));
if (textarea.value.length > maxChars) {
textarea.value = textarea.value.substring(0, maxChars);
}
charCount.textContent = textarea.value.length + "/" + maxChars;
}
</script>
</body>
</html>

0 comments on commit ec59536

Please sign in to comment.