I have a small question about using jquery.
I have the following code:
<html>
<head>
<script src="jquery/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("form").submit(function(){
if(!$(':text').val()){
$("span").text("sdfgsd").show();
};return false;
})
});
</script>
</head>
<body>
<form action="" id="ff" >
<span></span>
<input type="text" name="test" /> <br />
<input type="text" name="test3" /> <br />
<input type="checkbox" name="test2" /> <br />
<input type="submit" value="push it" />
</form>
</body>
the problem is that the selector is only activated for the first textbox. if you enter a value in the first textbox the trigger is not activated. neither :text or :input work properly.
does anyone have any ideas??
thanx in advance,
denisr
I’d suggest you to do something like that:
idorclassattributes to access elements because it’s more efficient and less prone to errorse.preventDefault()to prevent from submitting the formreturn false;to get out of theeachloop right away