Skip to content

Instantly share code, notes, and snippets.

@leowebguy
Last active January 16, 2016 04:52
Show Gist options
  • Save leowebguy/491267f0dd67cd6e2ab9 to your computer and use it in GitHub Desktop.
Save leowebguy/491267f0dd67cd6e2ab9 to your computer and use it in GitHub Desktop.
Textbox validation with jQuery (required field)
$(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