I implemented validation "required" in my "checkbox 'and it works, the" set focus "is on the field, but the validation message is not displayed!
<form asp-action="Create">
<div class="form-horizontal">
<h4>Etapa 4 - Termos de Uso</h4>
<h5>Para concluir a sua inscrição basta validar que você não é um robo e concordar com os termos de uso!</h5>
<hr />
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
</div>
<div class="form-group">
<div class="g-recaptcha" data-sitekey="6LcgsyITAAAAAHiF8A1MGysKGUfQddq-_uzBD8ba"></div>
</div>
<div class="form-group">
<div class="col-md-8 checkbox-inline">
<input asp-for="Aceite" required oninvalid="this.setCustomValidity('Para concluir a inscrição é necessário aceitar os termos de uso')"/>
Li e concordo com os termos de uso e privacidade
</div>
</div>
<div class="form-group">
<div class="col-md-8 checkbox-inline">
<input asp-for="AceitePromocao" />
<label asp-for="AceitePromocao"></label>
</div>
</div>
<div class="form-group">
<div class="col-md-pull-12">
<input type="submit" value="Aceitar e concluir" class="btn btn-success btn-lg" />
</div>
</div>
</form>
This is because a checkbox required validation is not logical. A checkbox can always be true or false. It's true when you're checking it otherwise false.
That means it always have a value.
Related
My application using vue3 to build devise sign up page and i'm using axios request to create user.
In registration controller, i found that params has added added an extra field name called registration data.
<ActionController::Parameters {"user"=>{"name"=>"name", "email"=>"mail", "phone"=>"123", "type"=>0}, "controller"=>"users/registrations", "action"=>"create", "registration"=>{"user"=>{"name"=>"name", "email"=>"mail", "phone"=>"123", "type"=>0}}}
It contains params[:user], that looks weird to me. Can someone explain?
"registration"=>{"user"=>{"name"=>"name", "email"=>"mail", "phone"=>"123", "type"=>0}
My form code:
methods: {
signUp: function(e) {
e.preventDefault();
let user_params = {
user: {
name: this.name,
email: this.email,
phone: this.phone,
type: this.type,
}
}
this.$http.post('/users', user_params)
.then(response => {
this.$emit('next');
}).catch(err => {
this.error = err.response.data;
});
},
}
And in view
<form>
<div class="col-md-6 col-sm-8 col-10 mt-5 mx-auto text-center">
<div class="checked-circle mx-auto">
<img :src="checkedStepImg" class="w-100 h-100">
</div>
<div class="title mt-5"> Let sign up for your account </div>
<div class="mt-3 text-red" v-if="error">{{ error }} </div>
<div class="row mt-3">
<div class="col-6">
<input class="form-control shadow-none rounded-0" placeholder="Name" v-model="name">
</div>
<div class="col-6">
<input class="form-control shadow-none rounded-0" placeholder="Email" v-model="email">
</div>
</div>
<div class="row mt-3">
<div class="col-6">
<div class="input-group">
<span class="input-group-text rounded-0">+1</span>
<input type="text" class="form-control shadow-none rounded-0 bg-white" placeholder="Phone" v-model="phone">
</div>
</div>
<div class="col-6">
<select class="form-select shadow-none rounded-0" aria-label="Default select example" v-model="type">
<option value="0" selected> Personal </option>
<option value="1"> Corporation </option>
</select>
</div>
</div>
<div class="col-6 col-sm-5 mx-auto btn-box mt-5">
<button class="btn btn-dark w-100 h-100" #click.prevent="signUp"> Sign up!</button>
</div>
</div>
</form>
That does not happen if i use a normal form devise sign_up
i'm using rails amp and setting my amp route for contact form
<form id='contactusform' method="POST" class="p2" action-xhr = "<%= addquery_path %>" custom-validation-reporting="as-you-go" target="_top">
<%= hidden_field_tag :authenticity_token, form_authenticity_token -%>
<div class="form-row">
<div class="inline-form">
<label class="inline-label">
<input type="text" id="as-you-go-name" pattern="p{L}+\s\p{L}+" class="inline-label-input input-item" name='name' value="" required />
<span class="inline-label-label">Name</span>
</label>
<div class="validation-blk">
<span visible-when-invalid="valueMissing" validation-for="as-you-go-name">Please enter your first name</span>
<span visible-when-invalid="patternMismatch" validation-for="as-you-go-name">Please enter characters only</span>
</div>
</div>
</div>
<div class="form-row">
<div class="inline-form">
<label class="inline-label">
<input type="email" id="as-you-go-email" class="inline-label-input input-item" value="" name='email' required />
<span class="inline-label-label">Email</span>
</label>
<span visible-when-invalid="valueMissing" validation-for="as-you-go-email">Please enter your email address</span>
<span visible-when-invalid="typeMismatch" validation-for="as-you-go-email"></span>
</div>
</div>
<div class="form-row">
<div class="inline-form">
<label class="inline-label">
<input type="number" id="phone-number" name='phone' class="inline-label-input input-item" value="" required />
<span class="inline-label-label">contatct number</span>
</label>
<span visible-when-invalid="valueMissing" validation-for="phone-number">Please enter your phone number</span>
</div>
</div>
<div class="form-row">
<div class="inline-form">
<label class="inline-label">
<input type="text" id="Cityname" name='city' pattern="\w+\s\w+" class="inline-label-input input-item" value="" required />
<span class="inline-label-label">City</span>
</label>
<span visible-when-invalid="valueMissing" validation-for="Cityname">Please enter your City</span>
</div>
</div>
<div class="form-row">
<div class="inline-form">
<label class="inline-label">
<input type="text" id="Statename" pattern="\w+\s\w+" class="inline-label-input input-item" name='state 'value="" required />
<span class="inline-label-label">State</span>
</label>
<span visible-when-invalid="valueMissing" validation-for="Statename">Please enter your State</span>
</div>
</div>
<div class="form-row">
<div class="inline-form">
<label class="inline-label">
<input type="text" id="Country" pattern="\w+\s\w+" class="inline-label-input input-item" name='country' value="" required />
<span class="inline-label-label">Country</span>
</label>
<span visible-when-invalid="valueMissing" validation-for="Country">Please enter your Country</span>
</div>
</div>
<div class="form-row">
<div class="inline-form selectionbox">
<label class="inline-label">
<select class="select-box custom-select" required name="eventtype"
id="eventtype">
<option value="">QUERY TYPE</option>
<% #app_config.event_type.split('|').each do |event_name,index| %>
<option value="<%= event_name %>"><%= event_name %></option>
<% end %>
</select>
</label>
<span visible-when-invalid="valueMissing" validation-for="eventtype">selectoption message appears like this</span>
</div>
</div>
<div class="form-row">
<div class="ampstart-input inline-block relative">
<textarea name="message" id="message" class="block" rows="5" cols="50" required placeholder="your message"></textarea>
<!-- <label class="textarea-ab" aria-hidden="true">
Your message
</label> -->
<span visible-when-invalid="valueMissing" validation-for="message"></span>
</div>
</div>
<div class="button button-common">
<input type="submit" value="OK" class="ampstart-btn caps">
</div>
<!-- social icons -->
<div submit-success>
<template type="amp-mustache">
Subscription successful!
</template>
</div>
<div submit-error>
<template type="amp-mustache">
Subscription failed!
</template>
</div>
</form>
And my controller saves the form in my database, but the browser throws an error.
def addquery
#contact = Lead.new
#contact.name = params[:name]
#contact.email = params[:email]
#contact.phone = params[:phone]
#contact.city = params[:city]
#contact.state = params[:state]
#contact.country = params[:country]
#contact.enquiry_type = params[:eventtype]
#contact.message = params[:message]
#contact.save
end
when i try to submit my AMP form it showing
amp form error request must have access-control-allow-origin
in my browser console.
as well as the
response must have access-control-allow-origin
Set access-control-allow-origin: <your domain> as a response header in the form handler in rails.
Example, if you are running on localhost set form response header as access-control-allow-origin: http://localhost:3000
I am trying to get values of form inputs on action method.
MVC View
#using (Html.BeginForm("Report", "Home"))
{
<div class="common_input Volunteer_input">
<div class="row">
<div class="col-sm-12">
<label for="firstName">Reporter:</label>
<div class="select_option_one">
<input type="text" id="ReporterCountries" class="ct-select2 ReporterCountriesList" />
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<label for="firstName">Partner:</label>
<div class="select_option_one">
<input type="text" name="PartnersCountries" id="PartnersCountries" class="ct-select2 CountryList" />
</div>
</div>
</div>
<h3>Comparators</h3>
<div class="row">
<div class="col-sm-12">
<label for="firstName">Partner:</label>
<div class="select_option_one">
<input type="text" name="CompareCountryList" id="CompareCountryList" class="ct-select2 CountryList" />
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<label for="firstName">Rank Growth:</label>
<div class="select_option_one">
<input type="text" name="RankGrowth" id="RankGrowth" class="ct-select2 RankGrowth" />
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="sub_submit">
<button type="submit" class="common_btn hvr-sweep-to-bottom">View<i class="fa fa-long-arrow-right"></i></button>
</div>
</div>
</div>
</div>
}
Action Method for Home Controller
public ActionResult Report(FormCollection form)
{
ViewData["ReporterCountries"] = Request.Form["ReporterCountries"];;
return RedirectToAction("Index","data");
}
When I try to retrieve the values of input on action controller I am receving all the control on the view but values are coming as null.
So I manage to solve the original problem by updating the package but here is what follows, a dark background with dark font color
Below is the codes for the view
<div *ngSwitchCase="'Basic'">
<md-card>
<md-card-content>
<h4>Basic Institution Subscription Page</h4>
<div class="row">
<div class="panel panel-default">
<div class="panel-heading">Your School or Institution Profile</div>
<div class="panel-body">
<md-card>
<md-card-content>
<div class="row" style="padding-left:10px;padding-bottom:10px;padding-top:20px">
<div class="col-md-6">
<img md-card-md-image [src]="'data:image/jpg;base64,' + institution.Crest" class="crest_image" style="margin-bottom:5px;margin-left:10px" />
<h6>Select Institution Crest</h6>
<input #crest type="file" (change)="crestChangeListner($event)" style="margin-left:20px" />
</div>
<div class="col-md-6">
<img md-card-md-image [src]="'data:image/jpg;base64,' + institution.BackGroundPicture" class="bgpic_image" style="margin-bottom:5px;margin-left:10px" />
<h6 *ngIf="!institution.BackGroundPicture">Select Background Image</h6>
<input #bgpic type="file" (change)="bgpicChangeListner($event)" style="margin-left:20px" />
</div>
</div>
<div class="row">
<div class="col-md-6">
<md-radio-group [(ngModel)]="institution.OwnershipCategory"
(change)="OwnershipCategorySelected($event.value)" name="ownershipCategory" class="example-margin"
[value]="institution.OwnershipCategory"
[align]="isAlignEnd ? 'end' : 'start'">
<md-radio-button class="icon-align-vertical" name="ownershipCategory" value="Public">
Public
</md-radio-button>
<md-radio-button class="icon-align-vertical" name="ownershipCategory" value="Private">
Private
</md-radio-button>
</md-radio-group>
</div>
</div>
<div class="row">
<div class="col-md-6">
<md-select placeholder="Select Country" style="width: 100%"
id="countryID" name="countryID" class="required"
[(ngModel)]="institution.Country"
(ngModelChange)="countrySelected()">
<md-option *ngFor="let country of countries" [value]="country.CountryID">
{{ country.CountryName }}
</md-option>
</md-select>
</div>
<div class="col-md-6">
<md-select placeholder="Select Office" style="width: 100%"
id="officeID" name="officeID" class="required"
[(ngModel)]="institution.OfficeID"
(ngModelChange)="officeSelected()">
<md-option *ngFor="let office of offices" [value]="office.AdministrativeStructureID">
{{ office.AdminStructName }}
</md-option>
</md-select>
</div>
</div>
<div class="row" *ngIf="offices">
</div>
<div class="row">
<div class="col-md-6">
<md-input-container style="width:100%">
<input mdInput name="InstitutionID" placeholder="Enter Institution ID"
[(ngModel)]="institution.InstitutionID" required id="InstitutionID" style="width: 100%"
#InstitutionID="ngModel">
<div [hidden]="InstitutionID.valid || InstitutionID.pristine"
class="alert alert-danger">
Institution ID is required
</div>
</md-input-container>
</div>
<div class="col-md-6">
<md-input-container style="width:100%">
<input mdInput placeholder="Enter Institution Name"
[(ngModel)]="institution.InstitutionName" name="InstitutionName" id="InstitutionName" required style="width: 100%"
#InstitutionName="ngModel">
<div [hidden]="InstitutionName.valid || InstitutionName.pristine"
class="alert alert-danger">
Institution Name is required
</div>
</md-input-container>
</div>
</div>
<div class="row">
<div class="col-md-6">
<md-input-container style="width:100%">
<input mdInput name="Website" placeholder="Enter Website Address"
[(ngModel)]="institution.Website" required id="Website" style="width: 100%"
#Website="ngModel">
<div [hidden]="Website.valid || Website.pristine"
class="alert alert-danger">
Website is required
</div>
</md-input-container>
</div>
<div class="col-md-6">
<md-input-container style="width:100%">
<input mdInput placeholder="Enter Email Address"
[(ngModel)]="institution.EmailAddress" name="EmailAddress" id="EmailAddress" required style="width: 100%"
#EmailAddress="ngModel">
<div [hidden]="EmailAddress.valid || EmailAddress.pristine"
class="alert alert-danger">
Email Address is required
</div>
</md-input-container>
</div>
</div>
<div class="row">
<div class="col-md-6">
<md-input-container style="width:100%">
<input mdInput name="PostalAddress" placeholder="Enter Postal Address"
[(ngModel)]="institution.PostalAddress" required id="PostalAddress" style="width: 100%"
#PostalAddress="ngModel">
<div [hidden]="PostalAddress.valid || PostalAddress.pristine"
class="alert alert-danger">
Postal Address is required
</div>
</md-input-container>
</div>
<div class="col-md-6">
<md-input-container style="width:100%">
<input mdInput placeholder="Enter Residential Address"
[(ngModel)]="institution.ResidentialAddress" name="ResidentialAddress" id="ResidentialAddress" required style="width: 100%"
#ResidentialAddress="ngModel">
<div [hidden]="ResidentialAddress.valid || ResidentialAddress.pristine"
class="alert alert-danger">
Residential Address is required
</div>
</md-input-container>
</div>
</div>
<div class="row">
<div class="col-md-6">
<md-input-container style="width:100%">
<input mdInput name="Phone1" placeholder="Enter Phone1"
[(ngModel)]="institution.Phone1" required id="Phone #1" style="width: 100%"
#Phone1="ngModel">
<div [hidden]="Phone1.valid || Phone1.pristine"
class="alert alert-danger">
Phone1 is required
</div>
</md-input-container>
</div>
<div class="col-md-6">
<md-input-container style="width:100%">
<input mdInput placeholder="Enter Phone2"
[(ngModel)]="institution.Phone2" name="Phone2" id="Phone #2" required style="width: 100%"
#Phone2="ngModel">
<div [hidden]="Phone2.valid || Phone2.pristine"
class="alert alert-danger">
Phone2 is required
</div>
</md-input-container>
</div>
</div>
<div class="row">
<div class="col-md-6">
<md2-datepicker
style="width:100%"
class="md-input-element"
placeholder="Select Date Founded"
name="DateFounded"
(ngModel)="institution.DateFounded"
[required]="isRequired"
[disabled]="isDisabled"
[openOnFocus]="isOpenOnFocus"
[isOpen]="isOpen"
[type]="type"
[min]="minDate"
[max]="maxDate">
</md2-datepicker>
</div>
<div class="col-md-6">
<div class="row">
<div class="col-md-4"><h6>Select Institution Catgory</h6></div>
<div class="col-md-8">
<md-radio-group [(ngModel)]="institution.SchoolCategory"
(change)="SchoolCategorySelected($event.value)" name="schoolCategory" class="example-margin"
[value]="institution.SchoolCategory"
[align]="isAlignEnd ? 'end' : 'start'">
<md-radio-button class="icon-align-vertical" name="schoolCategory" value="A">
A
</md-radio-button>
<md-radio-button class="icon-align-vertical" name="schoolCategory" value="B">
B
</md-radio-button>
<md-radio-button class="icon-align-vertical" name="schoolCategory" value="C">
C
</md-radio-button>
<md-radio-button class="icon-align-vertical" name="schoolCategory" value="D">
D
</md-radio-button>
<md-radio-button class="icon-align-vertical" name="schoolCategory" value="E">
E
</md-radio-button>
<md-radio-button class="icon-align-vertical" name="schoolCategory" value="F">
F
</md-radio-button>
</md-radio-group>
</div>
</div>
</div>
</div>
</md-card-content>
</md-card>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-heading">Shool Ownership In formation</div>
<div class="panel-body">
<md-card>
<md-card-content>
<div class="row">
<md-select placeholder="Select Owner Type" style="width: 100%"
id="ownershipTye" name="ownershipType" class="required"
[(ngModel)]="ownershipType"
(ngModelChange)="ownershipTypeSelected()">
<md-option *ngFor="let option of ownershipTypes" [value]="option">
{{ option }}
</md-option>
</md-select>
</div>
<div class="row">
<md-input-container style="width:100%">
<input mdInput name="fullName" placeholder="Enter Full Name"
[(ngModel)]="ownership.FullName" required id="fullName" style="width: 100%"
#fullName="ngModel">
<div [hidden]="fullName.valid || fullName.pristine"
class="alert alert-danger">
fullName is required
</div>
</md-input-container>
</div>
<div class="row">
<ul class="list-group">
<li class="list-group-item" *ngFor="let owner of ownerships">
<span class="badge">{{owner.FullName}}</span>
<md-checkbox name="ownerName"
(change)="fullNameSelected(owner)"
[(ngModel)]="owner.Selected">
{{owner.OwnershipTye}}
</md-checkbox>
</li>
</ul>
</div>
</md-card-content>
</md-card>
</div>
<div class="panel-footer">
<div class="row">
<div class="col-md-6">
<button md-raised-button color="primary" type="button" (click)="AddOwner()">Add Owner</button>
</div>
<div class="col-md-6">
<span class="pull-right">
<button md-raised-button color="primary" type="button" (click)="removeOwner()">Remove Owner</button>
</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</md-card-content>
</md-card>
</div>
and this part of the code for the component
isRequired = false;
isDisabled = false;
isOpenOnFocus = false;
isOpen = false;
type: string = 'date';
types: Array<any> = [
{ text: 'Date', value: 'date' },
{ text: 'Time', value: 'time' },
{ text: 'Date Time', value: 'datetime' }];
openDatepicker() {
this.isOpen = true;
setTimeout(() => {
this.isOpen = false;
}, 1000);
}
//startDate: Date = null;
setDate() {
this.institution.DateFounded = new Date();
}
minDate: Date = null;
maxDate: Date = null;
setDateRange() {
this.minDate = new Date();
this.minDate.setMonth(this.minDate.getMonth() - 3);
this.maxDate = new Date();
this.maxDate.setMonth(this.maxDate.getMonth() + 3);
}
I have a multistep form wizard that go through seven(7) steps.
image
Controllers:
private RegistrationEntities db = new RegistrationEntities();
public ActionResult Index()
{
return View();
}
View:
<div class="title_right">
<div class="col-md-5 col-sm-5 col-xs-12 form-group pull-right top_search">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search for...">
<span class="input-group-btn">
<button class="btn btn-default" type="button">Go!</button>
</span>
</div>
</div>
</div>
</div>
<div class="clearfix"></div>
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="x_panel">
<div class="x_title">
<h2>Contractors <small>Pre-Registration</small></h2>
<ul class="nav navbar-right panel_toolbox">
<li>
<a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
</li>
<li class="dropdown">
<i class="fa fa-wrench"></i>
<ul class="dropdown-menu" role="menu">
<li>
Settings 1
</li>
<li>
Settings 2
</li>
</ul>
</li>
<li>
<a class="close-link"><i class="fa fa-close"></i></a>
</li>
</ul>
<div class="clearfix"></div>
</div>
<div class="x_content">
<p>Kindly Follow the Procedures for the Pre-Registration Process.</p>
<div id="wizard" class="form_wizard wizard_horizontal">
<ul class="wizard_steps">
<li>
<a href="#step-1">
<span class="step_no">1</span>
<span class="step_descr">
Step 1<br />
<small>Step 1: Ownership Confirmation</small>
</span>
</a>
</li>
<li>
<a href="#step-2">
<span class="step_no">2</span>
<span class="step_descr">
Step 2<br />
<small>Step 2: RC Number</small>
</span>
</a>
</li>
<li>
<a href="#step-3">
<span class="step_no">3</span>
<span class="step_descr">
Step 3<br />
<small>Step 3: Company Name</small>
</span>
</a>
</li>
<li>
<a href="#step-4">
<span class="step_no">4</span>
<span class="step_descr">
Step 4<br />
<small>Step 4: TIN Number/Company Details</small>
</span>
</a>
</li>
<li>
<a href="#step-5">
<span class="step_no">5</span>
<span class="step_descr">
Step 5<br />
<small>Step 5: Company's Email</small>
</span>
</a>
</li>
<li>
<a href="#step-6">
<span class="step_no">6</span>
<span class="step_descr">
Step 6<br />
<small>Step 6: Other Company Details</small>
</span>
</a>
</li>
<li>
<a href="#step-7">
<span class="step_no">7</span>
<span class="step_descr">
Step 7<br />
<small>Step 7: Captcha</small>
</span>
</a>
</li>
</ul>
<div id="step-1">
<form class="form-horizontal form-label-left">
<div class="form-group">
<div class="col-lg-12">
<div class="col-lg-3">
<div class="form-group">
</div>
</div>
<div class="col-lg-6">
<div class="form-group">
<div class="radio">
#Html.RadioButtonFor(m => m.OWNERSHIP_STRUCTURE, 1, new { #class = "DoPopup", id = "Foreign Company", value = "" }) Foreign Company
</div>
<div class="radio">
#Html.RadioButtonFor(m => m.OWNERSHIP_STRUCTURE, 2, new { #class = "DoPopup", id = "Foreign Owned Nigerian Company", value = "" }) Foreign Owned Nigerian Company
</div>
<div class="radio">
#Html.RadioButtonFor(m => m.OWNERSHIP_STRUCTURE, 3, new { #class = "DoPopup", id = "Nigerian Company", value = "" }) Nigerian Company
</div>
</div>
</div>
<div class="col-lg-3">
<div class="form-group">
</div>
</div>
</div>
</div>
</form>
</div>
<div id="step-2">
#*<h2 class="StepTitle">Step 2 Content</h2>*#
<form class="form-horizontal form-label-left">
<div class="col-lg-12">
<div class="form-group">
#Html.LabelFor(model => model.RC_NUMBER, new { #class = "col-lg-2 control-label" })
<div class="col-lg-9">
#Html.TextBoxFor(model => model.RC_NUMBER, new { #class = "form-control" })
#Html.ValidationMessageFor(model => model.RC_NUMBER)
</div>
</div>
</div>
</form>
</div>
<div id="step-3">
#*<h2 class="StepTitle">Step 3 Content</h2>*#
<form class="form-horizontal form-label-left">
<div class="form-group">
<div class="col-lg-12">
<div class="form-group">
#Html.LabelFor(model => model.COMPANY_NAME, new { #class = "col-lg-2 control-label" })
<div class="col-lg-9">
#Html.TextBoxFor(model => model.COMPANY_NAME, new { #class = "form-control" })
#Html.ValidationMessageFor(model => model.COMPANY_NAME)
</div>
</div>
</div>
</div>
</form>
</div>
<div id="step-5">
<form class="form-horizontal form-label-left">
<div class="col-lg-12">
<div class="form-group">
#Html.LabelFor(model => model.COMPANY_CONTACT_EMAIL, new { #class = "col-lg-2 control-label" })
<div class="col-lg-9">
#Html.TextBoxFor(model => model.COMPANY_CONTACT_EMAIL, new { #class = "form-control" })
#Html.ValidationMessageFor(model => model.COMPANY_CONTACT_EMAIL)
</div>
</div>
</div>
</form>
</div>
<div id="step-6">
<form class="form-horizontal form-label-left">
<div class="col-lg-12">
<div class="form-group">
<div class="col-lg-2">
Alternative E-mail
</div>
<div class="col-lg-9">
#Html.TextBoxFor(model => model.COMPANY_CONTACT_ALTERNATIVE_EMAIL, new { #class = "form-control" })
#Html.ValidationMessageFor(model => model.COMPANY_CONTACT_ALTERNATIVE_EMAIL)
</div>
</div>
</div>
<div class="col-lg-12">
<div class="form-group">
<div class="col-lg-2">
Website
</div>
<div class="col-lg-9">
#Html.TextBoxFor(model => model.WEBSITE, new { #class = "form-control" })
#Html.ValidationMessageFor(model => model.WEBSITE)
</div>
</div>
</div>
<h3>Login Details</h3>
<hr />
<div class="col-lg-12">
<div class="col-lg-1">
</div>
<div class="form-group">
<div class="col-lg-2">
Username
</div>
<div class="col-lg-8">
#*<i class="glyphicon glyphicon-user"></i>*#
<input class="form-control input-lg" name="MERGE0" id="email" type="email" placeholder="Email address" required>
</div>
</div>
<div class="col-lg-1">
</div>
</div>
<div class="col-lg-12">
<div class="col-lg-1">
</div>
<div class="form-group">
<div class="col-lg-2">
Password
</div>
<div class="col-lg-8">
#*<i class="glyphicon glyphicon-user"></i>*#
<input class="form-control input-lg" name="MERGE1" id="password" type="password" placeholder="Password" required>
</div>
</div>
<div class="col-lg-1">
</div>
</div>
</form>
</div>
<div id="step-7">
<form class="form-horizontal form-label-left">
<div class="col-lg-12">
<div class="col-lg-1">
</div>
<div class="form-group">
<div class="col-lg-10">
#Html.MathCaptcha()
#* #Html.Captcha(3)*#
<br />
<p class="Error"> #ViewBag.ErrMessage </p>
</div>
</div>
<div class="col-lg-1">
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
}
<!-- jQuery Smart Wizard -->
<script>
$(document).ready(function () {
$('#wizard').smartWizard();
$('#wizard_verticle').smartWizard({
transitionEffect: 'slide'
});
$('.buttonNext').addClass('btn btn-success');
$('.buttonPrevious').addClass('btn btn-primary');
$('.buttonFinish').addClass('btn btn-default');
});
</script>
<!-- /jQuery Smart Wizard -->
The questions are:
How I I validate each step to make sure values are entered befor going to the next step
After completing the 7 steps, how do I valid that the values are entered properly before it saves.
After completing the 7th step, I clicked on the Finish button, no record was saved into the CONTRACTORS table
In step2, when RC_NUMBER is entered, it should check if it already exists. It should use it to populate COMPANY_NAME in step3, but if it doesnt exist, it should allow the user to enter COMPANY_NAME in step3
After completing the whole steps and Finish button is clicked, it should redirect to welcome model using ActionResult Welcome
Please check the answers to your questions below:
1.) jQuery SmartWizard allows us to add onLeaveStep:leaveAStepCallback field while declaring. leaveAStepCallback is the function that will be called when you click on the next button. You can implement your validation logic in this function. Please go through this URL to get the complete idea.
2.) jQuery SmartWizard also allows us to add onFinish:onFinishCallback field while declaring. In this case onFinishCallback function will be called after all the steps are completed. You can check here if all the inputs are valid and then submit the form. You must have got the idea if you had gone through the link in answer 1.
3.) You need to further elaborate why the details were not saved in DB? Is your controller action getting called? If yes, check your DB save logic to further find the issue as this is not the issue of SmartWizard.
4.) As I mentioned in the step 1 that bind a callback function to be called when next button is clicked. In this function, you can get the step number by using context.fromStep. After that you can make an ajax call to server to check if the value already exist. Implement your custom logic as required.
5.) If you are submitting form using $('form').submit(), you can redirect custom view from the controller after succesful operation. If you are making an ajax call, redirect to another controller in sucess function of ajax call.