Last active
January 16, 2016 04:52
-
-
Save leowebguy/491267f0dd67cd6e2ab9 to your computer and use it in GitHub Desktop.
Textbox validation with jQuery (required field)
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
$(document).ready(function () { | |
$('#submit').click(function (e) { | |
var isValid = true; | |
$('#firstname,#lastname,#email,#password').each(function () { | |
if ($.trim($(this).val()) == '') | |
{ | |
isValid = false; | |
$(this).css({ | |
"border": "1px solid red", | |
"background": "#FFCECE" | |
}); | |
} | |
else | |
{ | |
$(this).css({ | |
"border": "", | |
"background": "" | |
}); | |
} | |
}); | |
if (isValid == false) | |
e.preventDefault(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment