Skip to content
Snippets Groups Projects
Commit b4b084b1 authored by christos's avatar christos
Browse files

v3.1

parent a29f3333
Branches
No related merge requests found
......@@ -5,15 +5,57 @@ document.querySelector('#createPost button')
event.preventDefault()
console.log('Prevent')
var nam = document.getElementById('Fname');
var suj = document.getElementById('sujet');
var des = document.getElementById('Description');
if (document.getElementById('Fname').value ==''){
console.log('NULL')
var isValidSujet = true,
isValidFname = true,
isValidDes = true;
// if forms are NULL
try {
if (nam.value == '') throw "You didnt add a name";
if (suj.value == '') throw "You didnt add a subject name";
if (des.value == '') throw "You didnt add a Description";
}
catch(err) {
alert(err);
}
// Test of length
if (nam.value.length > 20) {
console.log('Trop long');
nam.style.borderColor="red";
isValidFname = false;
document.getElementById("p2").innerHTML +=
"20 char MAX.";
}
if (document.getElementById('Fname').value.lenght > 50) {
console.log('Trop long')
}
if (suj.value.length > 30) {
console.log('Sujet Trop long');
suj.style.borderColor="red";
isValidSujet = false;
document.getElementById("p1").innerHTML +=
"30 char MAX.";
}
if (des.value.length > 300) {
console.log('Sujet Trop long');
suj.style.borderColor="red";
isValidDes = false;
document.getElementById("p3").innerHTML +=
"300 char MAX.";
}
if ((isValidSujet) && (isValidFname) && (isValidSujet))
{
createPost.submit();
}
})
});
......@@ -5,15 +5,15 @@
<div class="post">
<form id="createPost">
<h2> Create a Post</h2>
<p>
<p id="p1">
<label for="sujet" class="plabel">Le nom du sujet:</label>
<input type="text" id="sujet" name="sujet">
</p>
<p>
<label for="Fname" class="plabel">Your name :</label>
<input type="text" id="Fname" name="Fname">
<p id="p2">
<label for="Fname" class="plabel">Your First name :</label>
<input type="text" id="Fname" name="Fname" >
</p>
<p>
<p id="p3">
<label for="Description" class="plabel">Description:</label>
<textarea id="Description" name="Description" placeholder="Write here ..." ></textarea>
</p>
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment