Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JavaScript]validacja moja problemy, moje wypociny nie działają
martex
post
Post #1





Grupa: Zarejestrowani
Postów: 133
Pomógł: 4
Dołączył: 7.11.2012
Skąd: Połaniec

Ostrzeżenie: (0%)
-----


Witam
Robię prostą walidacje ale mam problem aby była ona dla wszystkich inputów na stronie po id działa a jak chce po classach nic sie nie dzieje
ma ktoś pomysł jak to zrobić (IMG:style_emoticons/default/questionmark.gif)
generalnie ma to być tak że jeśli pola input puste to wyświetl diva z komunikatem

  1. <div class="errorAlert" style="display:none;">wypełnij pola.</div>
  2. <form>
  3. <input type="text" class="required" value="">
  4. <input type="text" class="required" value="">
  5. <input type="text" class="required" value="">
  6. <input type="submit" value="ok" class="das">
  7. </form>
  8.  
  9. <script type="text/javascript">
  10. $(document).ready(function (){
  11.  
  12. $("body").on("click", ".das", function(event){
  13. var validate = document.getElementsByClassName("required").value;
  14. if (validate.length == 0) {
  15. $('.errorAlert').css("display","block");
  16. //alert('Nie wpisałeś żadnej wartości!')
  17. } else {
  18. alert('tekst ' );
  19. }
  20. });
  21.  
  22. });
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 9.10.2025 - 10:37