Показать сообщение отдельно
  #1 (permalink)  
Старый 05.07.2017, 13:12
Новичок на форуме
Отправить личное сообщение для odrovunos Посмотреть профиль Найти все сообщения от odrovunos
 
Регистрация: 09.10.2016
Сообщений: 3

Верификация пользователя с помощью e-mail
Можете помочь? Я прошел краткий курс javaScript, не могу справиться. У меня задача написать код верификации пользователя через e-mail, в форме нужно ввести имя, фамилию, номер телефона, e-mail, после верного заполнения генерируется ссылка пройдя по которой происходит верификация пользователя.
Нашел в интернете части кода но, не могу их увязать.

<div><style type="text/css">
#ok {
background-color: #96070A;
display: none;
position: fixed;
z-index: 99999;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
#parent_popup {
background-color: #96070A;
display: none;
position: fixed;
z-index: 99999;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
#popup {
background: #ECE9E4;
width: 300px;
margin: 20% auto;
padding: 1px 1px 1px 1px;
border: 10px solid #ddd;
position: relative;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;

}

#btn{
background: rgb(212,75,56); /* фон кнопки */ color:#FFFFFF;
width: 150px;
padding: 10px 50px; /* отступ от текста */
//margin-left:79px;
//margin-right:0px;
margin-top:10px;
text-decoration: Bodoni MT;
font-size:12px !important;
border-radius: 3px;
}
#data
{
text-align: center;
margin: 1% auto;
width: 150px;
hight: 30px;
position: relative; top: 5px; left: 0%;
}
#btn:hover {background: #8BCD28; color:#000000;/* фон и цвет кнопки */} /* при наведении курсора мышки */
border-radius: 50%;}

}

input[type="text"], input[type="email"] {
width: 100px;
}
.invalid {
background: red;
}

</style>

</div>
<div id="parent_popup">
<div id="popup">
<form id="test">
<div>
<input type="text" title="имя"></input>
<input type="text" title="фамилия"></input>
<input type="text" title="мобильный номер"></input>
<input type="email" title="email"></input>
<span id="required"></span><br>
<input type="submit" >
</form>
</div>
<div id="ok">
</div>
</div>
<script>
window.onload = function() {

var form = document.forms[0],
fields = form.querySelectorAll('input[type="text"], input[type="email"]'),
msg = document.getElementById('required'),
regExp = [/^[А-Яа-яЁё]+$/, /.+@.+\..+/i, /^[А-Яа-яЁё\W\s\d]+$/, /^[А-Яа-яЁё\W\s\d]+$/];

form.onsubmit = function(event) {
var valid = true, cnt = 0;

event.preventDefault();

Array.prototype.forEach.call(fields, function(input) {
input.classList.remove('invalid');
if(!input.value.length) {
cnt++;
}
})

if(cnt == fields.length) {
Array.prototype.forEach.call(fields, function(input) {
input.classList.add('invalid');
})
msg.innerHTML = 'Заполните обязательные поля!';
return;
}

for (var i = 0, l = fields.length; i &lt; l; i++) {
fields[i].classList.remove('invalid');
if(!fields[i].value.match(regExp[i])) {
fields[i].classList.add('invalid');
msg.innerHTML = 'Неверно введено поле ' + fields[i].title + '!';
valid = false;
break;
}
}

if (valid) {
form.submit();
}

}
}
function fnLink() {
var strLink;

strLink = "http://www.sql.ru";

window.location.href = strLink
}
/* SmtpJS.com */
Email = { send: function (a, b, c, d, e, f, g) { var h = Math.floor(1e6 * Math.random() + 1), i = "https://smtpjs.com/smtp.aspx?"; i += "From=" + a, i += "&to=" + b, i += "&Subject=" + encodeURIComponent(c), i += "&Body=" + encodeURIComponent(d), void 0 == e.token ? (i += "&Host=" + e, i += "&Username=" + f, i += "&Password=" + g, i += "&Action=Send") : (i += "&SecureToken=" + e.token, i += "&Action=SendFromStored"), i += "&cachebuster=" + h, Email.ajax(i) }, sendWithAttachment: function (a, b, c, d, e, f, g, h) { var i = Math.floor(1e6 * Math.random() + 1), j = "https://smtpjs.com/smtp.aspx?"; j += "From=" + a, j += "&to=" + b, j += "&Subject=" + encodeURIComponent(c), j += "&Body=" + encodeURIComponent(d), j += "&Attachment=" + encodeURIComponent(h), void 0 == e.token ? (j += "&Host=" + e, j += "&Username=" + f, j += "&Password=" + g, j += "&Action=Send") : (j += "&SecureToken=" + e.token, j += "&Action=SendFromStored"), j += "&cachebuster=" + i, Email.ajax(j) }, ajax: function (a) { var b = Email.createCORSRequest("GET", a); b.onload = function () { var a = b.responseText; console.log(a) }, b.send() }, createCORSRequest: function (a, b) { var c = new XMLHttpRequest; return "withCredentials" in c ? c.open(a, b, !0) : "undefined" != typeof XDomainRequest ? (c = new XDomainRequest, c.open(a, b)) : c = null, c } };
</script>
Ответить с цитированием