I'm stuck why the .not() selector does not affect on validating. This is my HTML form:
<input name="Title" id="Title" type="text" />
<div id="ErrorTitle" class="hiddenbox"></div>
<input name="Text" id="Text" type="text" />
<div id="ErrorText" class="hiddenbox"></div>
<input name="Price" id="Price" type="text" />
<div id="ErrorPrice" class="hiddenbox"></div>
And this the jquery:
if($('#Title').val() == '')
{
$('#Title').focus();
ErrorBox('Please enter title', 'ErrorTitle'); // Write message in .hiddenbox
$('.hiddenbox').not('#ErrorTitle .hiddenbox').hide();
}
else if($('#Text').val() == '')
{
$('#Text').focus();
ErrorBox('Please enter text', 'ErrorText'); // Write message in .hiddenbox
$('.hiddenbox').not('#ErrorText .hiddenbox').hide();
}
else if($('#Price').val() == '')
{
$('#Price').focus();
ErrorBox('Please enter price', 'ErrorPrice'); // Write message in .hiddenbox
$('.hiddenbox').not('#ErrorPrice .hiddenbox').hide();
}
When submitting the form no one error message would display! Do I wrong it?!
not('#ErrorTitle')there is no need to class selectorCSSselectors before starting to code. Space denotes hierarchy.