Hi,
I posted http://stackoverflow.com/questions/3278074/alert-with-jquery-on-button-click but when I try to comment or click the Solution thingy nothing happens(?). I had forgot a "
However, I now have
$("input[value='OK']").click(function() {
if ($("input[title='Start Date']").val().length < 1)
{
$("input[title='Start Date']").val('Required field');
return false;
}
if ($("input[title='Target Date']").val().length < 1)
{
$("input[title='Target Date']").val('Required field');
return false;
}
});
If both start date and target date are empty it adds "required field" to the start date textbox and then reloads the page. Why isn't return false working and instead of adding required field to the target date textbox it reloads the page. If I have a start date and no target date it adds required field to the target date textbox and then reloads.
Ultimately I want to add something like <br/><span class="validate">Required field</span>
after the datetime picker.
Any ideas?
I can some mod add Aardsquid's answer to my other question as the right answer? Thanks
Edit: for some reason I can edit my question but not post comment nor click the Correct Answer thingy.
the ID of the form is aspnetForm so I should have something like
$('#aspnetForm').submit(function() {
if ($("input[title='Start Date']").val().length < 1)
{ $("input[title='Start Date']").val('Required field'); return false; } if ($("input[title='Target Date']").val().length < 1) { $("input[title='Target Date']").val('Required field'); return false; } if ($("input[title='People Picker']").val().length < 1) { $("input[title='People Picker']").val('Required field'); return false; } return true;
});
?