views:

20

answers:

2

I`m newbie in jquery.

Got the following code:

`<ul> <li><input type = "text"> <input type = "button" value = "Save">

How do I validate the textbox for user input required on clicking the button save and display error message next to the save button?

+1  A: 

There appears to be a Validation Plug-In for jQuery. Have you looked at this already?

If not, it appears to do exactly what you want, and there is plenty of documentation right there to get started.

Brabster
+1  A: 

You can try something like

<html>
<head>
<script type="text/javascript">
function Test(txtCheck, lblCheck)
{
    if (txtCheck.value == "")
        lblCheck.innerHTML = "Textbox is empty";
    else
        lblCheck.innerHTML = "";
}
</script>
</head>
<body>
    <input type="text" id="txtCheck" />
    <input type="button" value="Save" onclick="Test(txtCheck, lblCheck);"/>
    <label id="lblCheck"/>
</body>
astander