...

View Full Version : Resolved Messages showing when shouldn't be



CoolAsCarlito
11-23-2010, 10:42 PM
When I have this form loading its loading both messages when I told it to hide it and don't know why. Does anyone else? I looked inside the source code of the form and it's not saying the jquery function is involved.




<script type="text/javascript">
$(document).ready(function() {
$('div.message message-error').hide();
$('div.message message-success').hide();
$("input.submit").click(function() {
$('div.message message-error').hide();
var divisionname = $("input#divisionname").val();
if (divisionname == "") {
$("div.message message-error").show();
$("input#name").focus();
return false;
}
var dataString = 'divisionname='+ divisioname;
$.ajax({
type: "POST",
url: "bin/process.php",
data: dataString,
success: function() {
$("div.message message-success").show();
return true;
}
});
return false;
});
});

</script>
<!-- Form -->
<form action="" name="divisionform">
<fieldset>
<legend>Add New Division</legend>

<div class="field required">
<label for="divisionname">Division Name</label>
<input type="text" class="text" name="divisionname" id="divisionname" title="Division Name"/>
<span class="required-icon tooltip" id="" title="Required field - This field is required, it cannot be blank, and must contain something that is different from emptyness in order to be filled in. ">Required</span>
</div>
<input type="submit" class="submit" name="submitdivision" id="submitdivision" title="Submit Division" value="Submit Division"/>
</fieldset>
</form>
<div class="message message-error">
<h6>Required field missing</h6>
<p>Please fill in all required fields. </p>
</div>
<div class="message message-success">
<h6>Operation succesful</h6>
<p>Everything's going according to plan.</p>
</div>
<!-- /Form -->

BIOSTALL
11-23-2010, 10:59 PM
I think you need to change:


$('div.message message-error').hide();
$('div.message message-success').hide();

To:


$('div.message.message-error').hide();
$('div.message.message-success').hide();

Or:


$('div.message-error').hide();
$('div.message-success').hide();

Or:


$('.message-error').hide();
$('.message-success').hide();

Haven't tested it but hopefully that will do it :)

CoolAsCarlito
11-23-2010, 11:20 PM
Fixed. Thank you.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum