 <?php
defined('BASEPATH') OR exit('No direct script access allowed');
header("Access-Control-Allow-Origin: *");
?>
<!-- REGISTRATION FORM TALENTO -->
            <div id="RegistrarTalento" class="text-center"  style="padding:10px 0;">
                <div class="text-center">
                     <div class="logo">Registro</div>
                    <div class="login-form-1">
                        <form id="register-form" class="text-left" method="POST" name="datos">
                            <div class="login-form-main-message"></div>
                            <div class="main-login-form">
                            <div class="login-group">
                                <div class="form-group">
									<label for="nombre" class="sr-only">Nombre</label>
									<input type="text" class="form-control" id="nombre" name="nombre" placeholder="Nombre" required>
								</div>
								<div class="form-group">
									<select id="pais" style="width: 250px" name="pais" class="colorPlace" onchange="Peticiones.obtenerEstado('estado');" required>
										<option value="0">País...</option>
										<?php
											foreach ($paises as $p) {
												echo '<option value="'.$p->FIPAISID.'">'.$p->FCNOMBRE.'</option>';
											}
										?>
									</select>
								</div>
								<div class="form-group">
									<select id="estado" style="width: 250px" name="estado" class="colorPlace" disabled onchange="Peticiones.obtenerMunicipio('municipio');" required>
										<option value="0">Estado...</option>
									</select>
								</div>
								<div class="form-group">
									<select id="municipio" style="width: 250px" name="municipio" class="colorPlace" disabled required>
										<option value="0">Municipio...</option>
									</select>
								</div>
							<!--	<div class="form-group">
									<label for="direccion" class="sr-only">Dirección</label>
									<input type="text" class="form-control" id="direccion" name="direccion" placeholder="Dirección" required>
								</div> -->
								<div class="form-group">
									<label for="telefono" class="sr-only">Teléfono</label>
									<input type="telefono" class="form-control" id="telefono" name="telefono" placeholder="Teléfono" pattern="[0-9]{6,14}" title="El teléfono solo puede contener números. Min.6 Max.14" required>
								</div>
								<div class="form-group">
									<label for="email" class="sr-only">Email</label>
									<input type="email" class="form-control" id="email" name="email" placeholder="Email" required>
								</div>
								<div class="form-group">
									<label for="password" class="sr-only">Contraseña</label>
									<input type="password" class="form-control" id="password" name="password" placeholder="Password" pattern="(?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$" title="La contraseña debe contener: *Minimo 8 caracteres
*Al menos una letra mayúscula
*Al menos una letra minúscula
*Al menos un dígito o caracter especial." onchange="
											this.setCustomValidity(this.validity.patternMismatch ? this.title : '');
										  if(this.checkValidity()) form.password_confirm.pattern = this.value;" required>
								</div>
								<div class="form-group">
									<label for="password_confirm" class="sr-only">Confirmar contraseña</label>
									<input type="password" onpaste="return false" title="Las contraseñas no coinciden" class="form-control" id="password_confirm" name="password_confirm" placeholder="Confirma password" onchange="
									this.setCustomValidity(this.validity.patternMismatch ? this.title : '');" required>
								</div>
								<div class="form-group login-group-checkbox">
									<input type="checkbox" class="" id="reg_agree" name="reg_agree" required>
									<label for="reg_agree">Acepto<a style="color:black" href="<?=base_url()?>public/docs/Terminos_de_Uso.pdf" target="_blank"> Términos de uso y Políticas</a></label>
								</div>
                             <button  name="ok" id="ok" value="Aceptar" type="submit" class="login-button"><i class="fa fa-chevron-right"></i></button>
                            </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>

<br>
<div class='row' class='col-xs-18 col-sm-12'>
    <p class="bg-danger" id="info"></p>
</div>

<script type="text/javascript">

$("#register-form").on('submit', (function (e) {
        e.preventDefault();
        $.ajax({
            url: '<?= base_url() ?>VerifyLogin/insert_talento',
            type: "POST",
            data:  new FormData(this),
            contentType: false,
            cache: false,
            processData: false,
            success: function (data)
            {
               if (data.result == 'error') {
                    $('#info').html(data.value);
					setTimeout(" $('#info').html('');",3000);
					
                }
			  else if (data.result == 'errorlogueo') {
                  $('#info').html(data.value);
					setTimeout(" $('#info').html('');",3000);
                }
			 else if (data.result == 'talento') {
				 window.location.href = '<?= base_url() ?>candidatos';
			 }
            },
            error: function (data)
            {
                $('#error').html(data);
            }
        });
    }));

</script>                            

