SimpleModal, , CSS. , , auto
$("#sample").modal({
containerCss:{
backgroundColor:"#fff",
borderColor:"#0063dc",
height:450,
padding:0,
width:830
}
});
, , px (, "450px").
, . , , :
<div id="myDiv">
<form ...>
Enter your name: <input id="txtYourName" type="text" name="YourName" value="" />
<span id="errorYourName"></span>
<input type="submit" ... />
<input id="updated" type="hidden" />
</form>
</div>
, .
$(document).ready(function() {
$("#txtYourName").live("blur", function() {
if (validateInput($("#txtYourName").val())) {
$("#errorYourName").html("");
} else {
$("#errorYourName").html("This name is not valid.");
$("#updated").trigger('change');
}
});
$("#updated").change(function(){
})
});
, SimpleModal.
: , , . . ( SimpleModal ).
CSS
#myDiv { line-Height: 25px; }
#simplemodal-container { background-color:#444; border:8px solid #777; padding: 12px; }
.simplemodal-wrap { overflow: hidden !important; }
.error { color: #f00; display: none; }
input { float: right; }
HTML
<div id="myDiv">
<form>
What is your name: <input id="txtYourName" type="text" name="YourName" value="" /><br>
<div id="errorYourName" class="error">This name isn't Arthur.</div>
What is your quest: <input id="txtYourQuest" type="text" name="YourQuest" value="" /><br>
<div id="errorYourQuest" class="error">This quest must be for the Grail.</div>
What is your favorite color: <input id="txtYourColor" type="text" name="YourColor" value="" /><br>
<div id="errorYourColor" class="error">Sorry, you must like red or blue.</div>
What is the air speed velocity of an unladen swallow:<br>
Type:
<select>
<option>African</option>
<option>European</option>
</select>
<input id="txtYourGuess" type="text" name="YourGuess" value="" /><br>
<div id="errorYourGuess" class="error">This guess stinks.</div>
<hr>
<input id="submitMe" type="submit" />
</form>
</div>
$(document).ready(function(){
$("#myDiv").modal({
containerCss:{
height: '165px',
width: '350px'
}
})
$("#txtYourName").focus();
addValidate('#txtYourName','Arthur','#errorYourName');
addValidate('#txtYourQuest','Grail|grail','#errorYourQuest');
addValidate('#txtYourColor','red|blue','#errorYourColor');
addValidate('#txtYourGuess','11|24','#errorYourGuess');
$("#myDiv form").change(function() {
});
})
function addValidate(el,valid,err){
$(el).blur(function() {
if ( $(el).val().length > 0 && !$(el).val().match(valid) ) {
if ($(err).is(':hidden')) {
$('#simplemodal-container').animate({'height': ($('#simplemodal-container').height() + 25) + 'px'},1000);
$(err).slideDown(1000);
}
} else {
if ($(err).is(':visible')) {
$('#simplemodal-container').animate({'height': ($('#simplemodal-container').height() - 25) + 'px'},1000);
$(err).slideUp(1000);
}
}
});
}