Created
November 23, 2017 18:06
-
-
Save n05la3/183db88aa0a0f3595d30115d59e9968c to your computer and use it in GitHub Desktop.
Notify when required form field is skipped
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
<script> | |
$('document').ready( | |
function(){ | |
$('input').on('click focus', | |
function(){ | |
//sample form id in order of appearance | |
var fillable = ['fn', 'ln', 'age', 'email', 'pass', 'pass_ok']; | |
$('input').css('border', ''); | |
for(var i = 0; i<=fillable.indexOf(this.id); ++i){ | |
z = $('#'+fillable[i]); | |
//reset border to default | |
if(this.id === fillable[i]){ | |
$(z).css('border', ''); | |
//y.style.border = ''; | |
break; | |
} | |
if( $(z).val() === ''){ | |
//sample notification | |
$(z).css('border','2px solid red'); | |
//y.placeholder = y.placeholder + ' is required'; | |
break; | |
} | |
} | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment