How to validate phone number in JavaScript

Regular expressions are a right way to validate text fields such as phone numbers, names, addresses, age, date and other input information. You can use them to constrain input, apply formatting rules, and check lengths.
Continue reading “How to validate phone number in JavaScript”

Prompt Dialog Box in JavaScript

Suppose you want to require user interaction on the webpage for example if you want to display a dialog box that has some predefined message, a textbox that accepts user input and Ok and cancel button then we can use prompt dialog box in JavaScript.we know that Alert dialog box simply dislays information in a browser and does not allow any user interaction.
In prompt dialog box if user click on ‘Ok’ button then text types inside the textbox will be pass to the program environment otherwise if user click on ‘Cancel‘ button then it return null to the environment.

Prompt() method requires two blocks of information:
A message to be displayed as a prompt to the user
Any message to be displayed in the textbox, this is optional.
we can use Prompt() in JavaScript as:

prompt(“message“,”default value“)


    <script language="javascript">
       document.write(prompt("Please enter your name :"," Name"));

The Strict Equality Operators


JavaScript introduces two new operators, the strict equality operators.
The strict equality operators (=== and !==) perform equality comparisons on operands of the same type. No type conversion is performed before the comparison. They should be both Integer, String, or any other JavaScript type:

operand1 === operand2
operand1 !== operand2

Continue reading “The Strict Equality Operators”