Function to validate CNIC using Regex

Solution In JQuery var checkCNIC = function (textBox) { debugger; var regexp = new RegExp('^[0-9+]{5}-[0-9+]{7}-[0-9]{1}$'); var check = textBox.value; if (!regexp.test(check)) { alert('Invalid CNIC'); $(textBox).css('border-color', 'red'); return false; } else { $(textBox).css('border-color', 'green'); $(textBox).value = check; return true; } } In HTML @Html.TextBox("AddCNIC", null, new { @class = "form-control text-box", @placeholder = "11111-1111111-1", @onchange =... Continue Reading →

Bitwise and Bitshift Operators in Different Languages

NameLanguagesOperatorExplanationExampleBitwise ANDJava /Python/C/PHP/Javascript /SQL & The & operator compares corresponding bits of two operands. If both bits are 1, it gives 1. If either of the bits is not 1, it gives 0.  a = 55 & 21; Bitwise ORJava /Python/C /PHP/Javascript /SQL | The | operator compares corresponding bits of two operands. If either of the bits is... Continue Reading →

Conditional or ternary Operator in Different Languages

? is the conditional operator or the ternary operator. This operator consists of three operands and is used to evaluate Boolean expressions. The goal of the operator is to decide; which value should be assigned to the variable. SyntaxExampleExplanationC/Java/Javascript/C# conditionalExpression ? expression1 : expression2 days= (February == '1') ? 29 : 28; If February is... Continue Reading →

Comparison Operators in Different Languages

NameComparison OperatorsPython/Java/C/C#Javascript PHPSQLPowershellEqual to=======-eqGreater than>>>>-gtLess than<<<<-ltGreater than or Equal to>=>=>=>=-geLess than or Equal to<=<=<=<=-leNot Equal to!=!=!=<>-neIdentical===Not Identical!==Spaceship <=>  Equal value and equal type === Not equal value or not equal type !==Wildcard Comparison-likeWildcard Comparison -notlikeRegular Expression Comparison-match Regular Expression Comparison -notmatchReplace Operator-replace Containment operator -containsContainment operator -notcontains Like –contains, but with the operands reversed.(PowerShell 3.0)... Continue Reading →

Function to validate name for numbers and special characters

Solution In Jquery var ValidateName= function (usr) { var regexp = new RegExp('^[A-Za-z]+$'); var check = $(usr).val(); if (!regexp.test(check)) { alert('Numbers and Special Characters are not allowed'); $('#UserRole').css('border-color', 'red'); return false; } else { $('#UserRole').css('border-color', 'green'); return true; } } HTML <div class="col-sm-4 tb-font"> @Html.Label("Role", "User Role", new { style = "width:140px; margin-bottom:5px; margin-top:5px; float:... Continue Reading →

Function to Compare text of Password and Confirm Password field and placing it in document.ready function

Solution <script> $(document).ready(function () { $('#Password, #CPassword').on('change', function () { var ps = $("#Password").val(); var cps = $("#CPassword").val(); if (ps != null && ps != '' && cps != null && cps != '') { if (ps != cps) { alert("Please Enter the same Password in both fields"); $('#Password').css('border-color', 'red'); $('#CPassword').css('border-color', 'red'); } else {... Continue Reading →

Blog at WordPress.com.

Up ↑

Design a site like this with WordPress.com
Get started