کار با شیوهنامههای فرمها در بوت استرپ 4
نویسنده: وحید نصیری
تاریخ: ۱۳۹۷/۰۷/۲۶ ۱۴:۱۰
آدرس: www.dntips.ir
| مطالب | ۳۶۹۴ |
| نویسندگان | ۲۷۶ |
| گروههای مطالب | ۱۰۲۴ |
| نقشههای راه | ۱۱۹ |
| دورهها | ۱۴ |
| اشتراکها | ۱۷۹۱۴ |
<body>
<div class="container">
<h2>Medical Questionnaire</h2>
<form>
<fieldset>
<legend>Owner Info</legend>
<div>
<label for="ownername">Owner name</label>
<input type="text" id="ownername" placeholder="Your Name">
</div>
<div>
<label for="owneremail">Email address</label>
<input type="email" id="owneremail" aria-describedby="emailHelp"
placeholder="Enter email">
<small id="emailHelp">We'll never share your email</small>
</div>
</fieldset>
<fieldset>
<legend>Pet Info</legend>
<div>
<label for="petname">Pet name</label>
<input type="text" id="petname" placeholder="Your Pet's name">
</div>
<div>
<label for="pettype">Pet type</label>
<select id="pettype">
<option>Choose</option>
<option value="cat">Dog</option>
<option value="cat">Cat</option>
<option value="bird">Other</option>
</select>
</div>
<div>
<label for="reasonforvisit">Reason for today's visit</label>
<textarea id="reasonforvisit" rows="3"></textarea>
</div>
<div>
<label>Has your pet been spayed or neutered?</label>
<label><input type="radio" name="spayneut" value="yes"
checked> Yes</label>
<label><input type="radio" name="spayneut" value="no"> No</label>
</div>
<div>
<label>Has the pet had any of the following in the past 30
days</label>
<label><input type="checkbox"> Abdominal pain</label>
<label><input type="checkbox"> Lack of appetite</label>
<label><input type="checkbox"> Weakness</label>
</div>
</fieldset>
<button type="submit">Submit</button>
</form>
</div><!-- content container -->
</body>
<div class="form-check">
<label class="form-check-label">
<input class="form-check-input" type="checkbox">
Lack of appetite
</label>
</div> <div class="form-group">
<label class="d-block">Has your pet been spayed or
neutered?</label>
<div class="form-check form-check-inline">
<label class="form-check-label">
<input class="form-check-input" type="radio" name="spayneut"
value="yes" checked>
Yes
</label>
</div>
<div class="form-check form-check-inline">
<label class="form-check-label">
<input class="form-check-input" type="radio" name="spayneut"
value="no"> No
</label>
</div>
</div>
<div class="form-group">
<label for="owneremail" class="text-success">Email address</label>
<input class="form-control is-valid" type="email" id="owneremail"
aria-describedby="emailHelp" placeholder="Enter email">
<small class="form-text text-muted" id="emailHelp">We'll
never share your email</small>
<div class="valid-feedback">
Looks good!
</div>
</div>
<body>
<div class="container">
<h2>Medical Questionnaire</h2>
<form>
<fieldset class="form-group">
<legend>Owner Info</legend>
<div class="form-group row">
<label class="form-control-label col-md-2 col-form-label text-md-right"
for="ownername">Owner</label>
<div class="col-md-10">
<input class="form-control" type="text" id="ownername"
placeholder="Your Name">
</div>
</div>
<div class="form-group row">
<label class="form-control-label col-md-2 col-form-label text-md-right"
for="owneremail">Address</label>
<div class="col-md-10">
<input class="form-control" type="text" id="owneremail"
placeholder="Address">
</div>
</div>
<div class="form-group row">
<div class="form-group col-6 offset-md-2">
<label class="form-control-label sr-only" for="ownercity">City</label>
<input class="form-control" type="text" id="ownercity"
placeholder="City">
</div>
<div class="form-group col-md-4 col-6">
<label class="form-control-label sr-only" for="ownerzip">Zip</label>
<input class="form-control" type="text" id="ownerzip"
placeholder="Zip">
</div>
</div>
<div class="form-group row">
<div class="offset-md-2 col-md-10">
<button class="btn btn-primary" type="submit">Submit</button>
</div>
</div>
</fieldset>
</form>
</div>
</body>
<div class="form-group row">
<label class="form-control-label col-md-2 col-form-label text-md-right"
for="ownername">Owner</label>
<div class="col-md-10">
<input class="form-control" type="text" id="ownername"
placeholder="Your Name">
</div>
</div> <div class="form-group row"> <div class="form-group col-6 offset-md-2"> <label class="form-control-label sr-only" for="ownercity">City</label> <input class="form-control" type="text" id="ownercity"placeholder="City"> </div>
<div class="form-group row">
<div class="offset-md-2 col-md-10">
<button class="btn btn-primary" type="submit">Submit</button>
</div>
</div> <div class="form-group">
<label class="form-control-label" for="donationamt">
Donation Amount
</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">$</span>
</div>
<input type="text" class="form-control" id="donationamt"
placeholder="Amount">
<div class="input-group-append">
<span class="input-group-text">.00</span>
</div>
</div>
</div>
<nav class="navbar bg-dark navbar-dark navbar-expand-sm">
<div class="container">
<div class="navbar-brand d-none d-sm-inline-block">
Wisdom Pet Medicine
</div>
<div class="navbar-nav mr-auto">
<a class="nav-item nav-link active" href="#">Home</a>
<a class="nav-item nav-link" href="#">Mission</a>
<a class="nav-item nav-link" href="#">Services</a>
<a class="nav-item nav-link" href="#">Staff</a>
<a class="nav-item nav-link" href="#">Testimonials</a>
</div>
<form class="form-inline d-none d-md-inline-block">
<div class="input-group">
<label for="search" class="form-control-label sr-only"></label>
<input type="text" id="search" class="form-control"
placeholder="Search ...">
<div class="input-group-append">
<button class="btn btn-outline-light" type="submit">Go</button>
</div>
</div>
</form>
</div>
</nav>
$.validator.setDefaults({
ignore: "", // for hidden tabs and also textarea's
errorElement: 'span',
errorPlacement: function (error, element) {
error.addClass('invalid-feedback');
element.closest('.form-group').append(error);
},
highlight: function (element, errorClass, validClass) {
if (element.type === 'radio') {
this.findByName(element.name).addClass(errorClass).removeClass(validClass);
} else {
$(element).addClass(errorClass).removeClass(validClass);
$(element).addClass('is-invalid').removeClass('is-valid');
$(element).closest('.form-group').find('.input-group-text, label').removeClass('text-success').addClass('text-danger');
}
$(element).trigger('highlited');
},
unhighlight: function (element, errorClass, validClass) {
if (element.type === 'radio') {
this.findByName(element.name).removeClass(errorClass).addClass(validClass);
} else {
$(element).removeClass(errorClass).addClass(validClass);
$(element).removeClass('is-invalid').addClass('is-valid');
$(element).closest('.form-group').find('.input-group-text, label').removeClass('text-danger').addClass('text-success');
}
$(element).trigger('unhighlited');
}
});
function removeAllTagsAndTrim(html) {
return !html ? "" : $.trim(html.replace(/(<([^>]+)>)/ig, ""));
}
$.validator.methods.originalRequired = $.validator.methods.required;
$.validator.addMethod("required", function (value, element, param) {
value = removeAllTagsAndTrim(value);
if (!value) {
return false;
}
return $.validator.methods.originalRequired.call(this, value, element, param);
}, $.validator.messages.required);