[Solved] about GULP and application development [closed]

Gulp is a build system or tool in javascript built on node streams. Basically its a task runner and does automated time-consuming and repetitive tasks involved in web development. So no, we cant use gulp alone to develop UI and complete application but with the help of gulp we can do front end web development. … Read more

[Solved] convert Decimal to signed 2’s compliment and vice versa in vanilla javascript

Check this out may it will help you. (function(){ var ConvertBase = function (num) { return { from : function (baseFrom) { return { to : function (baseTo) { return parseInt(num, baseFrom).toString(baseTo); } }; } }; }; // binary to decimal ConvertBase.bin2dec = function (num) { return ConvertBase(num).from(2).to(10); }; // binary to hexadecimal ConvertBase.bin2hex = … Read more

[Solved] Javascript regex pattern for specific case

I need to split it to get only 1 and 6 and I only want whole number I want to ignore the floating numbers You can use String.prototype.split() with RegExp /\D|\d+\.\d+/ to split characters that are not digits, or digits followed by . character followed by digits to handle for example 2.456, Array.prototype.filter() with parameter … Read more

[Solved] Javascript variable functions

Since this code is littered with ternary operators, that seems to be what you are having the most trouble with. Basic syntax: condition ? a : b is the same as if (condition) { a } else { b } For weight: If you want to use kilo, just remove that whole line and set … Read more

[Solved] Is it possible to code in jQuery in a JS file? (.js)

Option -1: Download the jquery file and store it in the directory of the project and add the script tag in your html file and then add second js file which you can write jquery <script src=”https://stackoverflow.com/questions/37921952/jquery.min.js”></script> <script src=”main.js”></script> //Here you can write your custom js with jquery loaded first Option -2 : First take … Read more

[Solved] Email and mobile number validation on same html5 textbox with button

here is the simple javascript code which will validate both email and phone number. <html> <head> <script src=”https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js”></script> <script> function ValidateEmail(mail) { var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/; // if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm.emailAddr.value)) if(mail.match(mailformat)) { alert(mail); return (true) } alert(“You have entered an invalid email address!”) return (false) } function validate() { var data=document.getElementById(“email”).value; checkNumberorEmail(); } function phonenumber(inputtxt) { … Read more

[Solved] Form Password Validation without using regex [duplicate]

As you now accepted to use RegEx, I adapted the solution based on this post https://stackoverflow.com/a/16707675/4339170: function validate() { var p = document.getElementById(‘pass’).value var errors = [] //if (p.length < 8) { // errors.push(“Your password must be at least 8 characters”) //} if (p.search(/[a-z]/) < 0) { errors.push(“Your password must contain at least one lowercase … Read more

[Solved] why my jquery code is not working?

Try with following code: <script> $(document).ready(function(){ $(“[id^=tolevel_]”).click(function(){ var currentID = $(this).attr(“id”); var number = currentID.replace(“tolevel_”,””);//get the number in string format number = parseInt(number); var i = number -1; $(“#level_” + i).hide(500,’swing’, function(){ $(“#level_” +(i+1)).show(500, ‘swing’, function(){ }); }); }); $(“[id^=backtolevel_]”).click(function(){ var currentID = $(this).attr(“id”); var number = currentID.replace(“backtolevel_”,””);//get the number in string format number = … Read more

[Solved] javascript finding a string in a string

I don’t know Node.js but in javascript it can be done using split() var content = “Hello \n bob \n ben je op deze \n world \n bobert”, content_array = content.split(“\n”); content_array.forEach(function(entry) { document.write(“<content>’+entry+'</content><br />”); }); 1 solved javascript finding a string in a string

[Solved] Javascript validation error not valid value N/A [closed]

Assuming the string “N/A” is without anything leading or tailing you can do the following var na = contentOfYourTextbox; if(!na.match(/^N\s*[/]\s*A$/)){ alert(“I’m sorry, Dave. I’m afraid I can’t do that.”); } else { // do whatever you have plannned to do when the user entered “N/A” } 2 solved Javascript validation error not valid value N/A … Read more