<html>
<head>
<script>
function readTextFile(file)
{
var myFile = new XMLHttpRequest();
myFile.open("GET", file, false);
myFile.onreadystatechange = function ()
{
if(myFile.readyState === 4)
{
if(myFile.status === 200 || myFile.status == 0)
{
var allText = myFile.responseText;
document.getElementById("hsBoard").innerHTML = allText;
}
}
}
myFile.send(null);
}
</script>
</head>
<body>
<div id='hsBoard'>
Click On Read button to Read File
</div>
<br />
<input type="button" value="Read" onClick="readTextFile('hs.txt')" /><br />
</body>
</html>
<html>
<head>
<SCRIPT LANGUAGE="JAVASCRIPT">
<!-- hide this script tag's contents from old browsers
function lifetimer(){
today = new Date()
BirthDay = new Date(document.live.age.value)
timeold = (today.getTime() - BirthDay.getTime());
sectimeold = timeold / 1000;
secondsold = Math.floor(sectimeold);
msPerDay = 24 * 60 * 60 * 1000 ;
timeold = (today.getTime() - BirthDay.getTime());
e_daysold = timeold / msPerDay;
daysold = Math.floor(e_daysold);
e_hrsold = (e_daysold - daysold)*24;
hrsold = Math.floor(e_hrsold);
minsold = Math.floor((e_hrsold - hrsold)*60);
document.live.time1.value = daysold
document.live.time2.value = hrsold
document.live.time3.value = minsold
window.status = "Well at the moment you are " + secondsold + "............ seconds old.";
timerID = setTimeout("lifetimer()",1000)
}
// -- done hiding from old browsers -->
</script>
</head>
<body>
<FORM name="live">
Please enter your age::<INPUT TYPE="text" NAME="age" VALUE="" SIZE=20>
Example: (november 1,1966) <BR><BR><BR>
<INPUT TYPE="button" NAME="start" VALUE="Start Timer" ONCLICK="lifetimer(this.form)">
<INPUT TYPE="reset" NAME="resetb" VALUE="Reset Age">
<BR><BR>
<TABLE border=0>
<TR><TD>You are days old:</TD>
<TD>
<INPUT TYPE="text" NAME="time1" VALUE="" size=8>
</TD>
</TR>
<TR><TD>Plus hours old:</TD>
<TD>
<INPUT TYPE="text" NAME="time2" VALUE="" size=8>
</TD>
</TR>
<TR><TD>Plus minutes old:</TD>
<TD><INPUT TYPE="text" NAME="time3" VALUE="" size=8></TD>
</TR>
</TABLE>
</FORM>
<br />
</body>
</html>
document.live.time3.value = minsold
today = new Date()
<html>
<head>
</head>
<body>
<form method="POST">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%">
<textarea rows="12" name="charcount" cols="60" wrap="virtual"></textarea>
</td>
</tr>
<tr>
<td width="100%"><div align="right"><p><input type="button" value="Calculate Characters"
onClick="countit(this)"> <input type="text" name="displaycount" size="20"></p>
<div align="center"><center><p>This free script provided by
<a href="http://javascriptkit.com">JavaScript
Kit</a></p>
</center></div></div></td>
</tr>
</table>
</form>
<script language="JavaScript">
function countit(what){
//Character count script- by javascriptkit.com
//Visit JavaScript Kit (http://javascriptkit.com) for script
//Credit must stay intact for use
formcontent=what.form.charcount.value
what.form.displaycount.value=formcontent.length
}
</script>
<br />
</body>
</html>
const source = document.getElementById('source');
const result = document.getElementById('result');
const inputHandler = function(e) {
result.innerText = e.target.value;
}
source.addEventListener('input', inputHandler);
source.addEventListener('propertychange', inputHandler);
<input id="source">
<div id="result"></div>
<div id='result'>
</div>
public function betalk_checkPassword($betalkpwd, &$errors) {
$errors_init = $errors;
if (strlen($betalkpwd) < 8) {
$errors[] = "رمزعبور حداقل باید 8 کاراکتر باشد";
}
if (!preg_match("#[0-9]+#", $betalkpwd)) {
$errors[] = "حداقل باید یک عدد داخل رمزعبور باشد";
}
if (!preg_match("#[a-zA-Z]+#", $betalkpwd)) {
$errors[] = "حداقل باید یک حرف انگلیسی داخل رمزعبور باشد";
}
if (!preg_match("#[A-Z]+#", $betalkpwd)) {
$errors[] = "حداقل باید یک حرف انگلیسی بزرگ داخل رمزعبور باشد";
}
if (!preg_match("#/[\[^\'£$%^&*()}{@:\'#~?><>,;@\|\\\-=\-_+\-¬\`\]]/+#", $betalkpwd)) {
$errors[] = "حداقل باید یک کاراکتر خاص داخل رمزعبور باشد";
}
return ($errors == $errors_init);
}
<script>
function validatePassword(password) {
// مخفی کردن پیام رمزعبور هنگامی که فیلد خالی است
if (password.length === 0) {
document.getElementById("msg").innerHTML = "";
return;
}
// تعریف شرط برای کاراکترهای رمزعبور
var matchedCase = new Array();
matchedCase.push("[$@$!%*#?&]"); // کاراکترهای خاص
matchedCase.push("[A-Z]"); // حروف بزرگ
matchedCase.push("[0-9]"); // اعداد
matchedCase.push("[a-z]"); // حروف کوچک
// بررسی شرایط
var ctr = 0;
for (var i = 0; i < matchedCase.length; i++) {
if (new RegExp(matchedCase[i]).test(password)) {
ctr++;
}
}
// نمایش متن
var color = "";
var strength = "";
switch (ctr) {
case 0:
case 1:
case 2:
strength = "بسیار ضعیف";
color = "red";
break;
case 3:
strength = "متوسط";
color = "orange";
break;
case 4:
strength = "قوی";
color = "green";
break;
}
document.getElementById("msg").innerHTML = strength;
document.getElementById("msg").style.color = color;
}
</script>
<button type="submit" onclick="validatePassword()">ثبت</button>
<span id="msg"></span>
const source = document.getElementById('source');
const result = document.getElementById('result');
const inputHandler = function(e) {
result.innerText = e.target.value;
}
source.addEventListener('input', inputHandler);
source.addEventListener('propertychange', inputHandler);
<input id="source">
<div id="result"></div>
<div id='result'>
</div>
const inputHandler = function(e) {
result.innerText = e.target.value;
var reg = /^([A-Z]){1}([a-z]){2,10}$/;
if(reg.test(e.target.value) == false) {
alert('harfe aval bayad englisi bozorg bashad va 2 ta 10 harf kochak englisi badesh bashe');
return false;
}
}
let text = e.target.value;
let length = text.length;
if (length>3)
{
کد بررسی رگولار اکسپرژن
}
var reg = /^([A-Z]){1}([a-z]){2,10}([0-9]){0,4}$/;
$check = preg_match('/^([A-Z]){1}([a-z]){2,10}([0-9]){0,4}$/', $name);
if (! $check ) {
پیام دادم اسم شما مشکل دارد
و صفحه را بعد مدتی رفرش کردم.
$error=1;
echo "<meta http-equiv='refresh' content='70'>";
}