+ 3

Please help me with this form validation. I know its poorly written Im still learning.

/* Its main aim is to alert a person that more than 8 characters is too long. I also used Bootstrap in the process Here is the link to the code: https://code.sololearn.com/WPjDImi0ejv0/#js */ $(function() { $("#demo").keyup(function(){ var len = $("#demo").val(); if(len.length>8){ var el = $("<p></p>").html(""); $("#holder").append(el); $("p").addClass("alert alert-warning"); var x = $("<span></span>").html(" Too long"); $("p").append(x); $("span").addClass("glyphicon glyphicon-alert"); stop(); } else if(len.length<=8){ $("#holder p").children().remove(); } }); });

30th Jul 2019, 4:35 PM
John Makone
John Makone - avatar
2 Antworten
+ 1
16. $("#holder p").children().remove(); 👇 16. $("p").remove(); or 16. $("#holder").children().remove();
30th Jul 2019, 5:39 PM
Solo
Solo - avatar
+ 1
Vasiliy Thanks very much
1st Aug 2019, 9:18 AM
John Makone
John Makone - avatar