How to write a jquery function for same-type controls in html?
i'm designing a form which gets user information and then go another page.
There's lots of "input text" controls to fill. User must fill all "input
text" controls in order to go home page. if a control is empty, an "x"
icon should be put inside "input text".
My main problem is, i'm new at jquery and i dont want to write this
function for every control:
$('#send').click(function () {
if ($('#kname').val().length == 0) {
$('#kname').css({ background: "url(image/error.png)
no-repeat right" });
}
});
i need a general function for all controls. here is my html lines:
//some code
<input type="text" id="knumber" />
<input type="text" id="kname" />
<input type="text" id="ksurname" />
//some other code
edit: i'm using an "input button" to send these info.
<input type="button" value="Send Them" id="send" />
No comments:
Post a Comment