Created
May 31, 2013 00:11
-
-
Save vsync/5682214 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tämä: | |
$('div#inputwarning').hide(); // Piilotetaan virheilmoitus oletuksena | |
tulee | |
$(document).ready(function(){ | |
ja | |
$('.submit').click(function(){ | |
väliin | |
ja tämä: | |
var empty = 0; // Apumuuttuja | |
$(':input.required').each(function(){ | |
var field = $(this); | |
if($(this).val().length == 0) { // Jos vaadittu kenttä on tyhjä, asetetaan sille lisäluokka ja näytetään virheilmoitus | |
field.addClass('mustfill') | |
$('div#inputwarning').fadeIn(300); | |
empty = 1; | |
} | |
else field.removeClass('mustfill'); // Jos vaadittu kenttä ei ole tyhjä, poistetaan siltä (mahdollinen) lisäluokka | |
}); | |
if(empty) return false; // Jos löytyy tyhjiä kenttiä, lopetetaan js-tiedoston suoritus. | |
$('div#inputwarning').hide(); // Muuten piilotetaan (mahdollisesti) näkyvä virheilmoitus | |
tulee | |
$('.submit').click(function(){ | |
ja | |
// Haetaan formin inputtien valuet | |
väliin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment