I'm trying to use vee validate to verify the password using this code.
<div>
<input type="password"
placeholder="Password"
v-model="password"
v-validate="'required|min:6|max:35|confirmed'"
name="password" />
</div>
<div>
<span>{{ errors.first('password') }}</span>
</div>
<div>
<input type="password"
placeholder="Confirm password"
v-model="confirmPassword"
v-validate="'required|target:password'"
name="confirm_password" />
</div>
<div>
<span>{{ errors.first('confirm_password') }}</span>
</div>
But it always says The password confirmation does not match.
What went wrong in my code?
Your password input must have ref="password" - that's how vee-validate finds the target:
<input v-validate="'required'" ... ref="password"> (Thanks, Ryley).
confirmed:{target} - Input must have the same value as the target
input, specified by {target} as the target field’s name.
Also, there's an error with your Vee Validate syntax, change target: to confirmed:
v-validate="'required|target:password'"
should be
v-validate="'required|confirmed:password'"
Have a look at the basic example below, it will check for two things:
Does the second input field have any input value?
If yes, does the second input value match the first input value?
var app = new Vue({
el: '#app',
data: {
message: 'Hello Vue!'
}
})
body {
background: #20262E;
padding: 15px;
font-family: Helvetica;
}
#app {
width: 60%;
background: #fff;
border-radius: 10px;
padding: 15px;
margin: auto;
}
<script src="https://cdn.jsdelivr.net/npm/vue#2.5.17/dist/vue.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vee-validate/2.1.1/vee-validate.js"></script>
<script>
Vue.use(VeeValidate);
</script>
<div id="app">
<form id="demo">
<!-- INPUTS -->
<div class="input-group">
<h4 id="header"> Enter Password</h4>
<div class="input-fields">
<input v-validate="'required'" name="password" type="password" placeholder="Password" ref="password">
<input v-validate="'required|confirmed:password'" name="password_confirmation" type="password" placeholder="Password, Again" data-vv-as="password">
</div>
</div>
<!-- ERRORS -->
<div class="alert alert-danger" v-show="errors.any()">
<div v-if="errors.has('password')">
{{ errors.first('password') }}
</div>
<div v-if="errors.has('password_confirmation')">
{{ errors.first('password_confirmation') }}
</div>
</div>
</form>
</div>
Further reading: https://baianat.github.io/vee-validate/guide/rules.html#confirmed
Below code works for me: https://logaretm.github.io/vee-validate/advanced/cross-field-validation.html#targeting-other-fields
<template>
<ValidationObserver>
<ValidationProvider rules="required|password:#confirm" v-slot="{ errors }">
<input type="password" v-model="password" />
<span>{{ errors[0] }}</span>
</ValidationProvider>
<ValidationProvider name="confirm" rules="required" v-slot="{ errors }">
<input type="password" v-model="confirmation" />
<span>{{ errors[0] }}</span>
</ValidationProvider>
</ValidationObserver>
</template>
<script>
import { extend } from 'vee-validate';
extend('password', {
params: ['target'],
validate(value, { target }) {
return value === target;
},
message: 'Password confirmation does not match'
});
export default {
data: () => ({
password: '',
confirmation: ''
})
};
</script>
On Vee-validate 3.x.x another way of doing it is:
<template>
<ValidationObserver>
<ValidationProvider vid="password" rules="required" v-slot="{ errors }">
<input type="password" v-model="password" />
<span>{{ errors[0] }}</span>
</ValidationProvider>
<ValidationProvider name="confirm" rules="required|confirmed:password" v-slot="{ errors }">
<input type="password" v-model="confirmation" />
<span>{{ errors[0] }}</span>
</ValidationProvider>
</ValidationObserver>
</template>
<script>
import { extend } from 'vee-validate';
extend("confirmed", {
...confirmed,
message: "The password does not match",
});
export default {
data: () => ({
password: '',
confirmation: ''
})
};
</script>
Something import to notice is the vid prop on the first validation provider. It will NOT work without it.
Related
I have a laravel 9 project with livewire, jetstream, fullcalendar 5, alpine, and tailwind (TALL stack) based off of this project:
https://github.com/LaravelDaily/Laravel-Jetstream-CRUD-Roles
and this tutorial: https://laravel.sillo.org/liveware-fullcalendar/
I have the drag and drop functionality as well as the select and eventClick actions working with livewire that submit event data to the database. I've also got the CRUD functions for events and timeline resources contributing data to the calendar view. I'm trying to employ a modal for both the select function and the eventClick function that adds an event and edits an event respectively.
My issues are currently threefold:
Curently, thanks to #ADyson, I managed to get the livewire calendar element to launch a livewire modal element and retrieve PART of the data. The event title, start, and end times. I'm trying to also include additional fields in the events CRUD for event acronym, city, venue, etc...I think the issue here is that I have not specifically declared these as EventObjects like ExtendedProps.
a)I'm interested specifically in where the livewire calendar class might be edited and imagine it's in this stanza of the view file where the events are constructed from JSON like this
events: JSON.parse(#this.events),
b) and I assume the select and eventClick statements in the same file would need to have the event info function altered to retrieve this information as well.
Below is the current fullcalendar 5 view file calendar.blade.php:
<style>
#calendar-container {
display: grid;
grid-template-columns: 200px 1fr;
padding: 20px;
}
#events {
grid-column: 1;
}
#calendar {
grid-column: 2;
height: 700px;
}
.dropEvent {
background-color: DodgerBlue;
color: white;
padding: 5px 16px;
margin-bottom: 10px;
text-align: center;
display: inline-block;
font-size: 16px;
border-radius: 4px;
cursor:pointer;
}
</style>
<div>
#include('livewire.eventmodal')
<div>
<!-- sidebar -->
<div id="calendar-container" wire:ignore>
<div id="events">
<div data-event='{"title":"Evénement A"}' class="dropEvent">Event One Drag</div>
<div data-event='{"title":"Evénement B"}' class="dropEvent">Event Two Draggable</div>
</div>
<div id="calendar"></div>
</div>
</div>
</div>
#push('scripts')
<script src='https://cdn.jsdelivr.net/npm/fullcalendar-scheduler#5.10.1/main.min.js'></script>
<script>
create_UUID = () => {
let dt = new Date().getTime();
const uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
let r = (dt + Math.random() * 16) % 16 | 0;
dt = Math.floor(dt / 16);
return (c == 'x' ? r :(r&0x3|0x8)).toString(16);
});
return uuid;
}
document.addEventListener('livewire:load', function () {
const Calendar = FullCalendar.Calendar;
const calendarEl = document.getElementById('calendar');
const Draggable = FullCalendar.Draggable;
new Draggable(document.getElementById('events'), {
itemSelector: '.dropEvent'
});
const calendar = new Calendar(calendarEl, {
headerToolbar: {
left: 'promptResource prev,next today',
center: 'title',
right: 'resourceMonth,dayGridMonth,timeGridWeek,timeGridDay,listMonth'
},
views: {
resourceMonth: {
type: 'resourceTimelineMonth',
buttonText: 'personnel'
}
},
customButtons: {
promptResource: {
text: "+ personnel",
click: function() {
var title = prompt("Name");
if (title) {
calendar.addResource({
title: title
});
fetch("add_resources.php", {
method: "POST",
headers: {
Accept: "application/json"
},
body: encodeFormData({ title: title })
})
.then(response => console.log(response))
.catch(error => console.log(error));
}
}
}
},
initialView: 'resourceTimelineMonth',
locale: '{{ config('app.locale') }}',
events: JSON.parse(#this.events),
resourceAreaHeaderContent: 'Personnel',
resources: JSON.parse(#this.resources),
//'https://fullcalendar.io/api/demo-feeds/resources.json?with-nesting&with-colors',
editable: true,
eventResize: info => #this.eventChange(info.event),
eventDrop: info => #this.eventChange(info.event),
eventReceive: info => {
const id = create_UUID();
info.event.setProp('id', id);
#this.eventAdd(info.event);
},
selectable: true,
select: function(selectionInfo) {
$('#eventModal').modal('show');
},
eventClick: function(info) {
// Display the modal and set the values to the event values.
$('#updateEventModal').modal('show');
$('#updateEventModal').find('#title').val(info.event.title);
$('#updateEventModal').find('#acronym').val(info.event.acronym);
$('#updateEventModal').find('#city').val(info.event.city);
$('#updateEventModal').find('#start').val(info.event.start);
$('#updateEventModal').find('#end').val(info.event.end);
},
});
calendar.render();
});
</script>
<link href='https://cdn.jsdelivr.net/npm/fullcalendar-scheduler#5.11.3/main.min.css' rel='stylesheet' />
#endpush
I have further separated out the actual modal from being included in this file and it's a separate livewire element now called eventmodal.blade.php:
<!-- Insert Modal -->
<div wire:ignore.self class="modal fade" id="eventModal" tabindex="-1" aria-labelledby="eventModalLabel"
aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="eventModalLabel">Create Event</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"
wire:click="closeModal"></button>
</div>
<form wire:submit.prevent="saveEvent">
<div class="modal-body">
<div class="mb-3">
<label>Event Name</label>
<input type="text" id="title" wire:model="title" class="form-control">
#error('title') <span class="text-danger">{{ $message }}</span> #enderror
</div>
<div class="mb-3">
<label>Event Acronym</label>
<input type="text" id="acronym" wire:model="acronym" class="form-control">
#error('acronym') <span class="text-danger">{{ $message }}</span> #enderror
</div>
<div class="mb-3">
<label>Event City</label>
<input type="text" id="city" wire:model="city" class="form-control">
#error('city') <span class="text-danger">{{ $message }}</span> #enderror
</div>
<div class="mb-3">
<label>Event Venue</label>
<input type="text" id="venue" wire:model="venue" class="form-control">
#error('venue') <span class="text-danger">{{ $message }}</span> #enderror
</div>
<div class="mb-3">
<label>Event Value</label>
<input type="text" id="value" wire:model="value" class="form-control">
#error('value') <span class="text-danger">{{ $message }}</span> #enderror
</div>
<div class="mb-3">
<label>Event Start</label>
<input type="text" id="start" wire:model="start" class="form-control">
#error('start') <span class="text-danger">{{ $message }}</span> #enderror
</div>
<div class="mb-3">
<label>Event End</label>
<input type="text" id="end" wire:model="end" class="form-control">
#error('end') <span class="text-danger">{{ $message }}</span> #enderror
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" wire:click="closeModal"
data-bs-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Save</button>
</div>
</form>
</div>
</div>
</div>
<!-- Update Event Modal -->
<div wire:ignore.self class="modal fade" id="updateEventModal" tabindex="-1" aria-labelledby="updateEventModalLabel"
aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="updateEventModalLabel">Edit Event</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" wire:click="closeModal"
aria-label="Close"></button>
</div>
<form wire:submit.prevent="updateEvent">
<div class="modal-body">
<div class="mb-3">
<label>Event Name</label>
<input type="text" id="title" wire:model="title" class="form-control">
#error('title') <span class="text-danger">{{ $message }}</span> #enderror
</div>
<div class="mb-3">
<label>Event Acronym</label>
<input type="text" id="acronym" wire:model="acronym" class="form-control">
#error('acronym') <span class="text-danger">{{ $message }}</span> #enderror
</div>
<div class="mb-3">
<label>Event City</label>
<input type="text" id="city" wire:model="city" class="form-control">
#error('city') <span class="text-danger">{{ $message }}</span> #enderror
</div>
<div class="mb-3">
<label>Event Venue</label>
<input type="text" id="venue" wire:model="venue" class="form-control">
#error('venue') <span class="text-danger">{{ $message }}</span> #enderror
</div>
<div class="mb-3">
<label>Event Value</label>
<input type="text" id="value" wire:model="value" class="form-control">
#error('value') <span class="text-danger">{{ $message }}</span> #enderror
</div>
<div class="mb-3">
<label>Event Start</label>
<input type="text" id="start" wire:model="start" class="form-control">
#error('start') <span class="text-danger">{{ $message }}</span> #enderror
</div>
<div class="mb-3">
<label>Event End</label>
<input type="text" id="end" wire:model="end" class="form-control">
#error('end') <span class="text-danger">{{ $message }}</span> #enderror
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" wire:click="closeModal"
data-bs-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Update</button>
</div>
</form>
</div>
</div>
</div>
<!-- Delete Event Modal -->
<div wire:ignore.self class="modal fade" id="deleteEventModal" tabindex="-1" aria-labelledby="deleteEventModalLabel"
aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="deleteEventModalLabel">Delete Event</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" wire:click="closeModal"
aria-label="Close"></button>
</div>
<form wire:submit.prevent="destroyEvent">
<div class="modal-body">
<h4>Are you sure you want to delete this data ?</h4>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" wire:click="closeModal"
data-bs-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Yes! Delete</button>
</div>
</form>
</div>
</div>
</div>
Secondly, the current modals save functions are not working. I'm lost at where to start...do I need an additional route? Some additional code in the form of a controller?
Lastly, my select function...when you click on a date or a date range in the default fullcalendar view is not picking up the date ranges from fullcalendar as it does without the modal using the standard function like this:
select: arg => {
const title = prompt('Title :');
const id = create_UUID();
if (title) {
calendar.addEvent({
id: id,
title: title,
start: arg.start,
end: arg.end,
allDay: arg.allDay
});
#this.eventAdd(calendar.getEventById(id));
};
calendar.unselect();
Thanks to #ADyson, I've managed to retrieve the start and end date on the eventClick events within my livewire modal with the calendar.blade.php like so:
//...previously posted calendar view code above
select: function(selectionInfo) {
// Display the modal.
// You could fill in the start and end fields based on the parameters
$('#AddEventModal').modal('show');
},
eventClick: function(info) {
// Display the modal and set the values to the event values.
$('#AddEventModal').find('#title').val(info.event.title);
$('#AddEventModal').find('#acronym').val(info.event.acronym);
$('#AddEventModal').find('#start').val(info.event.start);
$('#AddEventModal').find('#end').val(info.event.end);
$('#AddEventModal').modal();
},
...
As you can see, I'm also trying to retrieve data from another field in the events table for 'acronym'. Perhaps the issue lies in either my livewire/calendar.php
<?php
namespace App\Http\Livewire;
use Livewire\Component;
use App\Models\Event;
use App\Models\Resource;
use Illuminate\Support\Arr;
class Calendar extends Component
{
public $events, $resources, $title, $acronym, $city, $venue, $value ;
public function eventChange ( $event )
{
$e=Event::find($event['id']) ;
$e->start=$event['start'] ;
$e->acronym=$event['acronym'] ;
if(Arr::exists($event,'end')) {
$e->end=$event['end'];
}
$e->save();
}
public function render()
{
$this->events=json_encode(Event::all());
$this->resources=json_encode(Resource::all());
return view('livewire.calendar');
}
public function eventAdd ( $event )
{
Event::create ( $event );
}
public function eventRemove ( $id )
{
Event::destroy ( $id );
}
public function resourceAdd ( $resources )
{
Resource::create ( $resources );
}
public function resourceRemove ( $id )
{
Resource::destroy ( $id );
}
}
I managed to get the first part of my issue resolved. FullCalendar 5, when retrieving the events via JSON automatically detects extendedProps that can be retrieved with the eventClick method like so:
eventClick: function(info) {
// Display the modal and set the values to the event values.
$('#updateEventModal').modal('show');
$('#updateEventModal').find('#title').val(info.event.title);
$('#updateEventModal').find('#acronym').val(info.event.extendedProps.acronym);
$('#updateEventModal').find('#city').val(info.event.extendedProps.city);
$('#updateEventModal').find('#venue').val(info.event.extendedProps.venue);
$('#updateEventModal').find('#value').val(info.event.extendedProps.value);
$('#updateEventModal').find('#start').val(info.event.start);
$('#updateEventModal').find('#end').val(info.event.end);
},
I have select option (dropdown list) inside a modal in which the option are getting printed below the dropdownlist... I tried checking if the code works if i redirect the page and works, like the options are inside the dropdown box but same thing inside modal doesn't work? Any solutions would be helpful.
add_details.blade
<div class="container">
<div class="row">
<div class="col">
<div>
<h2>Enter Your Details</h2>
<form action="{{ route('save') }}" method="POST" enctype="multipart/form-data">
#csrf
<div>
<div>
<span style="color:black">
<select class="form-control" name="collegeID" id="college_name" required />
<option value="" disabled selected hidden>Select College</option>
#foreach ($college_names as $college_name)
<option value="{{$college_name->collegeID}}">
{{ $college_name->college_name }}
</option>
#endforeach
</select>
</span>
</div>
</div>
<br />
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="form-group">
<input type="radio" value="Cbse" name="regno">
<label for="" style="color:black">CBSE</label>
<input type="radio" value="State" name="regno"> <label style="color:black">PUC</label>
<input type="radio" value="State" name="regno"> <label style="color:black">State</label>
<div id="showCbse" class="myDiv">
<label for="regno" class="form-label"><span style="color:black">Admission Number</span></label>
<input type="number" name="regno" class="form-control" placeholder="Enter valid Admission Number" />
#if ($errors->has('regno'))
<span class="text-danger">{{ $errors->first('regno') }}</span>
#endif
</div>
<div id="showState" class="myDiv">
<label for="regno" class="form-label"><span style="color:black">Register Number</span></label>
<input type="number" name="regno" class="form-control" placeholder="Enter valid Register Number" />
#if ($errors->has('regno'))
<span class="text-danger">{{ $errors->first('regno') }}</span>
#endif
</div>
</div>
</div>
</br>
<label for="name" class="form-label"><span style="color:black">Name</span></label>
<input type="text" name="name" class="form-control" value="{{old('name')}}" placeholder="Enter Name" required />
#if ($errors->has('name'))
<span class="help-block font-red-mint">
<strong>{{ $errors->first('name') }}</strong>
</span>
#endif
</div>
<div>
</br>
<label for="address" class="form-label"><span style="color:black">Address</span></label>
<input type="text" name="address" value="{{old('address')}}" class="form-control" placeholder="Enter Address" required />
#if ($errors->has('address'))
<span class="help-block font-red-mint">
<strong>{{ $errors->first('address') }}</strong>
</span>
#endif
</div>
<div>
</br>
<label for="yop" class="form-label"><span style="color:black">Year Of Passing</span></label>
<input type="date" name="yop" value="{{old('yop')}}" class="form-control" placeholder="Enter Year Of Passing" required />
#if ($errors->has('yop'))
<span class="help-block font-red-mint">
<strong>{{ $errors->first('yop') }}</strong>
</span>
#endif
</div>
<div>
</br>
<label for="email" class="form-label"><span style="color:black">Email</span></label>
<input type="email" name="email" value="{{old('email')}}" class="form-control" placeholder="Enter Email" required />
#if ($errors->has('email'))
<span class="help-block font-red-mint">
<strong>{{ $errors->first('email') }}</strong>
</span>
#endif
</div>
<div>
</br>
<label for="phone" class="form-label"><span style="color:black">Phone Number</span></label>
<input type="number" name="phone" value="{{old('phone')}}" class="form-control" placeholder="Enter Phone Number" required />
#if ($errors->has('phone'))
<span class="help-block font-red-mint">
<strong>{{ $errors->first('phone') }}</strong>
</span>
#endif
</div>
<br /> <br />
<div class="col-md-4">
</br>
<button type="submit" class="btn btn-primary">Add</button>
</form>
<button type="submit" class="btn btn-primary">Back</button>
</div>
</div>
<style>
.myDiv {
display: none;
padding: 10px;
}
</style>
<script>
$(document).ready(function() {
$('input[type="radio"]').click(function() {
var demovalue = $(this).val();
$("div.myDiv").hide();
$("#show" + demovalue).show();
});
});
</script>
add.blade (page where the modal pops up)
<link href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css" rel="stylesheet">
<link href="https://cdn.datatables.net/1.10.19/css/dataTables.bootstrap4.min.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.0/jquery.validate.js"></script>
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<script src="https://cdn.datatables.net/1.10.19/js/dataTables.bootstrap4.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs4/jszip-2.5.0/dt-1.10.20/b-1.6.1/b-flash-1.6.1/b-html5-1.6.1/b-print-1.6.1/r-2.2.3/datatables.min.css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.1/umd/popper.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.6.0/js/bootstrap.min.js"></script>
<!-- Font Awesome -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/js/all.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>
<!-- Datepicker -->
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<link href="css/bootstrap-select.min.css" rel="stylesheet" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<script src="https://cdn.datatables.net/1.10.12/js/dataTables.bootstrap.min.js"></script>
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.12/css/dataTables.bootstrap.min.css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="js/bootstrap-select.min.js"></script>
#extends('auth.dashboard')
#section('title')
Dashboard
#endsection
#section('body')
#if(Session::has('success'))
<div class="alert alert-success alert-dismissible">
{{Session::get('success')}}
</div>
#elseif(Session::has('failed'))
<div class="alert alert-success alert-dismissible">
{{Session::get('failed')}}
</div>
#endif
<body>
</br>
<div class="container">
<div class="row">
<div class="col">
<div>
<div class="pull-right">
<a class="btn btn-primary" title="Add"
href="{{route('add_details')}}"><i class="fas fa-plus-circle"></i></a>
<a class="btn btn-sm" data-toggle="modal" id="mediumButton" data-target="#mediumModal" data-attr="{{ route('add_details')}}" title="Add Institute Details"> ADD
</a>
</div>
</br>
</br>
</br>
<div class="row">
<div class="col-12 table-responsive">
<table class="table table-striped table-bordered user_datatable" id="user_datatable">
<thead class="thead-dark div-2">
<tr>
<center> <th><strong><span style="color:white">ID</span></strong></th> </center>
<th><strong><span style="color:white">Name</span></strong></th>
<th><span style="color:white">Status</span></th>
<th width="15%"><span style="color:white">Action</span></th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
<!-- medium modal -->
<div class="modal fade" id="mediumModal" tabindex="-1" role="dialog" aria-labelledby="mediumModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body" id="mediumBody">
<div>
<!-- the result to be displayed apply here -->
</div>
</div>
</div>
</div>
</div>
</body>
<script type="text/javascript" src="https://cdn.datatables.net/v/bs4/jszip-2.5.0/dt-1.10.20/b-1.6.1/b-flash-1.6.1/b-html5-1.6.1/b-print-1.6.1/r-2.2.3/datatables.min.js">
</script>
<script type="text/javascript" src="https://cdn.datatables.net/responsive/2.2.7/js/dataTables.responsive.min.js">
</script>
<script type="text/javascript">
$(document).ready(function() {
$.noConflict();
fill_datatable();
function fill_datatable(collegeID = '') {
var table = $('.user_datatable').DataTable({
order: [
[0, 'desc']
],
processing: true,
serverSide: true,
ajax: {
url: "{{ route('alumni.datatable') }}",
data: {
collegeID: collegeID
}
},
columns: [{
data: 'id',
name: 'id'
},
{
data: 'name',
name: 'name'
},
{
data: 'status',
name: 'status',
mRender: function(data) {
if (data == '1') {
return '<center><span class = "btn btn-danger btn-sm" > Pending </span></center>'
}
if (data == '0') {
return '<center><span class = "btn btn-success btn-sm" > Approved </span></center>'
}
}
},
{
data: 'action',
name: 'action',
orderable: false,
searchable: false
},
]
});
}
$('#filter').click(function() {
var collegeID = $('#college_name').val();
if (collegeID != '') {
$('#user_datatable').DataTable().destroy();
fill_datatable(collegeID);
} else {
alert('Select Both filter option');
}
});
});
</script>
<script>
// display a modal (medium modal)
$(document).on('click', '#mediumButton', function(event) {
event.preventDefault();
let href = $(this).attr('data-attr');
$.ajax({
url: href,
beforeSend: function() {
$('#loader').show();
},
// return the result
success: function(result) {
$('#mediumModal').modal("show");
$('#mediumBody').html(result).show();
},
complete: function() {
$('#loader').hide();
},
error: function(jqXHR, testStatus, error) {
console.log(error);
alert("Page " + href + " cannot open. Error:" + error);
$('#loader').hide();
},
timeout: 8000
})
});
</script>
#endsection
It's minor mistake all devs do :D , I also did this type of mistake.
use
<select class="form-control" name="collegeID" id="college_name" required>
Instead of this
<select class="form-control" name="collegeID" id="college_name" required />
Just remove close tag from end of the start tag.
User have to register through two steps. both steps have modal to fill details. for that i have two component ComponentA for first modal and componentB for second modal. Iwant to close first modal on axios success response and open second modal for second registration step.
<template>
<!--sction user-signup 1-->
<div class="signup">
<div class="modal" id="user-signup-1">
<div class="modal-dialog">
<div class="modal-content">
<button type="button" class="close" data-dismiss="modal">×</button>
<!-- Modal body -->
<div class="modal-body text-center" style="background:url(images/user-signup-bg.jpg) no-repeat left top; ">
<h2>SIGN UP</h2>
<h5 class="setp-tag">Step 1 of 2</h5>
<h6>Registered users have access to all MoneyBoy features. This is not a Moneyboy Profile.<br>
If you’d like to create a Moneyboy Profile please click here.</h6>
<form class="user-signup-form" action="./api/user/signup" method="POSt" #submit.prevent="addUser()">
<div class="form-group">
<label>Username</label>
<input type="text" name="username" v-model="username" placeholder="mohamed-ali" class="span3 form-control">
<span v-if="hidespan">5 - 20 characters. Letters A-Z and numbers 0-9 only. No spaces.
E.g. MikeMuscleNYC.</span>
<span v-if="errorinusername"> {{ errorinusername }}</span>
</div>
<div class="form-group">
<label>Email</label>
<input type="email" name="email" v-model="email" placeholder="mohamed-ali#gmail.com" class="span3 form-control">
<span v-if="errorinemail"> {{ errorinemail }}</span>
</div>
<div class="form-group">
<label>Create a password</label>
<input type="password" name="password" v-model="password" placeholder="**********" class="span3 form-control">
<span v-if="errorinusername"> {{ errorinpassword}}</span>
</div>
<div class="form-group turms">
<input name="" type="checkbox" value="1" v-model="checked" id="terms"><label for="terms">I am over 18 and agree to the
Terms & Conditions</label>
<!--<label><input type="checkbox" name="terms">I am over 18 and agree to the Terms & Conditions.</label>-->
<input type="submit" :disabled="!checked" value="SIGN UP NOW" class="btn btn-primary w-100">
</div>
<div class="form-group">
<p>If you’d like to create a Moneyboy Profile click here.</p>
</div>
<div class="clearfix"></div>
</form>
</div>
</div>
</div>
</div>
<usersignup2component #recordadded="openusersignup2modal()"></usersignup2component>
</div>
<!--sction user-signup 1-->
</template>
<!--sript -->
<script>
Vue.component('usersignup2component', require('./UserSignup2Component.vue').default);
export default {
data(){
return {
username: '',
email:'',
password:'',
checked: false,
errorinusername: '',
errorinemail: '',
errorinpassword: '',
hidespan: true,
}
},
methods:{
addUser(){
axios.post('./api/user/signup', {
username:this.username,
email:this.email,
password:this.password
})
.then((response) =>{
this.$emit('recordadded');
})
.catch((error) => {
console.log(error.response);
this.hidespan = false;
this.errorinusername = error.response.data.errors.username;
this.errorinemail = error.response.data.errors.email;
this.errorinpassword = error.response.data.errors.password;
});
},
openusersignup2modal(){
console.log('okkkkkkkkkkkkkk');
}
},
mounted() {
console.log('UserSignUp1Component mounted.')
}
}
</script>
What I am doing wrong. I tried to console.log() on openusersignup2modal method to see, if it this function ever called or not. Found no activity on openusersignup2modal()
DataSource gets json response data:
categoriesDS = new kendo.data.DataSource({
transport: {
read: {
url: "{{ path('get_json_categories') }}",
dataType: "json"
}
}
});
with white spaces:
{"categoryId":33,"parentId":32,"name":" [ ] p1"}
but rendering it without white spaces. How to change this behaviour?
edit: I need whitespaces in select options input. Below is my template script
<script id="popup_editor" type="text/x-kendo-template">
<form method="post" action="{{ path('updatedoc') }}" enctype="multipart/form-data">
<div class="k-edit-label">
<label for="documentFile">Plik</label>
</div>
<div data-container-for="documentFile" class="k-edit-field">
<input name="files" id="files" type="file" aria-label="files"/>
</div>
<input name="documentId" id="documentId" type="text" data-bind="value:documentId" style="display: none;"/>
<div class="k-edit-label">
<label for="documentDateAdd">Data Dodania</label>
</div>
<div class="k-edit-field">
<input type="text" class="k-input k-textbox k-state-disabled" name="documentDateAdd"
data-bind="value:documentDateAdd" disabled>
</div>
<div class="k-edit-label">
<label for="documentDesc">Opis</label>
</div>
<div data-container-for="documentDesc" class="k-edit-field">
<textarea name="documentDesc" class="k-textbox" data-bind="value:documentDesc"></textarea>
</div>
<div class="k-edit-label">
<label for="user">Twórca</label>
</div>
<div data-container-for="user" class="k-edit-field">
<input type="text" class="k-input k-textbox k-state-disabled" name="user" data-bind="value:user"
disabled>
</div>
<!-- dropdownlist-->
<div class="k-edit-label">
<label for="FacultyRankId">Kategoria</label>
</div>
<!-- dropdownlist editor for field: "FacultyRankId" -->
<div class="k-edit-field" id="categoriesDiv">
<input id="categoriesInput" name="categoryId"
{# tu wskazuję z którą wartością z data-source wiązać ten input tj z czym synchronizować, czyli
zmiany w inpucie na które pole ma wpływać z dataSource#}
data-bind="value:categoryId"
data-value-field="categoryId"
{#to co jest wyświetlane w dropdown#}
data-text-field="name"
data-source="categoriesDS"
data-role="dropdownlist"
data-value-primitive="true"
/>
</div>
<script type="text/javascript">
$('.k-edit-buttons:eq(1)').hide();
$("span.k-dropdown-wrap > span.k-input").each(function() {
console.log($(this).text());
var text = $(this).text().replace('PODKATEGORIA666, ', '. .');
$(this).text(text);
});
<\/script>
<div class="k-edit-buttons k-state-default">
<button type="submit" class="k-button k-primary"> Aktualizuj </button>
</div>
</form>
</script>
and style selector that didn't work:
<style>
input#categoriesInput { white-space: pre; }
</style>
(It looks like your post is mostly bar code; please add some more details.It looks like your post is mostly code; )
Try setting white-space style to pre and depending on the widget that you want to use it you will have to use different selectors.
Following an example for showing it in a drop down list:
<style>
span[aria-owns="color_listbox"] { white-space: pre; }
#color-list .k-item { white-space: pre; }
</style>
Following a snippet
$("#color").kendoDropDownList({
dataTextField: "text",
dataValueField: "value",
dataSource: [
{ text: " [ ] Black", value: "1" },
{ text: " [ ] Orange", value: "2" },
{ text: "Grey", value: "3" }
]
});
span[aria-owns="color_listbox"] {
white-space: pre;
}
#color-list .k-item {
white-space: pre;
}
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2018.1.221/styles/kendo.bootstrap-v4.min.css" />
<script src="https://kendo.cdn.telerik.com/2018.1.221/js/jquery.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2018.1.221/js/kendo.all.min.js"></script>
<input id="color" value="1" style="width: 100%;" />
I am using following versions:
"vue": "^2.1.0",
"vee-validate": "2.0.0-beta.14",
How do I debounce display of an error message.
I tried delay, v-delay and few other in following code but nothing seems to work.
<input type="number" v-validate data-rules="required|numeric" name="number" delay="1800"/>
In earlier version this used to happen via data-vv-delay.
Upgrade to the latest versions of Vue & VeeValidate, then continue using: data-vv-delay:
Vue.use(VeeValidate)
new Vue({
el: '#app',
})
.is-error {
border: 2px solid red;
}
.form-group {
margin-top: 20px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.1.3/vue.js"></script>
<script src="https://cdn.jsdelivr.net/vee-validate/2.0.0-beta.17/vee-validate.js"></script>
<div id="app">
<div class="form-group">
<label class="label" for="email">Email</label>
<input
v-validate
data-vv-rules="required|email"
:class="{'is-error': errors.has('email') }"
name="email"
type="text"
data-vv-delay="2000"
placeholder="Email">
<span v-show="errors.has('email')">
{{ errors.first('email') }}
</span>
</div>
<div class="form-group">
<label class="label" for="number">Number</label>
<input
v-validate
data-vv-rules="required|numeric"
:class="{'is-error': errors.has('number') }"
name="number"
type="number"
data-vv-delay="2000"
placeholder="Number">
<span v-show="errors.has('number')">
{{ errors.first('number') }}
</span>
</div>
</div>
The above snippet threw some errors when using your version (Vue 2.1.0 & VeeValidate beta 14). The issue seems to lie with beta 14 being a bit dodgy!