innerHTM实现失焦判断方法

innerHTM实现失焦判断方法,第1张

为了避免一些不友好的d窗提示,使用失焦事件innerHTML给用户友好提示,在以后的项目用户注册板块都可以用得到,代码如下:

<script>
function validate()
{
documentgetElementById("udiv")innerHTML="";
documentgetElementById("pdiv")innerHTML="";
documentgetElementById("adiv")innerHTML="";

var isok = true;
if(documentgetElementById("userName")value=="")
{
documentgetElementById("udiv")innerHTML="用户名不能为空";
isok = false;
}
if(documentgetElementById("passWord")value=="")
{
documentgetElementById("pdiv")innerHTML="密码不能为空";

isok = false;
}
if(documentgetElementById("passWord")valuelength<6)
{
documentgetElementById("pdiv")innerHTML="密码长度不应小于6位";
isok = false;
}

if(documentgetElementById("age")value=="")
{
documentgetElementById("adiv")innerHTML="年龄不能为空";
isok = false;
}
if(isNaN(documentgetElementById("age")value))
{
documentgetElementById("adiv")innerHTML="年龄必须为数字";
isok = false;

}
return isok;
}
</script>

<form action="2html" name="frm" onsubmit="return validate()">
用户名:<input type="text" name="userName"><span id="udiv"></span><br>
密码:<input type="password" name="passWord"><span id="pdiv"></span><br>
年龄:<input type="text" name="age"><span id="adiv"></span><br>

<input type="submit" value="提 交">
</form>

<label class='radio-inline'>
<input type="radio" name="lala" value="1" {if $questiones['state']==1}checked{/if} /> 是
</label>
<label class='radio-inline'>
<input type="radio" name="lala" value="0" {if $questiones['state']==0}checked{/if} /> 否
</label>
以上代码参考一下,这是HTML前端代码,IF语句里面的变量需在PHP申明。

最简单就是用windowopen啊
windowopen('abchtm','win1','top=0,left=200,width=320,height=400,scrollbars=no,resizable=yes,center:yes');
//三个参数分别为新窗口的文件路径(也可以是部分script函数);第二个参数是窗口名;第三个参数是窗口状态
只要第二个参数(窗口名)有写, 就只会d出一个窗口。

{$userrichname} 这写法是你后台定制的模板处理还是变量 如果是, 在 net 里cs 文件里有 $user这个对象 和 $user_UC 变量,那也可以写成 <%= $user_UC != ""$user_UC:$userusersex %> 跟java的一样的。
或者写一个在 aspx 对应的cs 类里加个诸如 string FixUserName (string $user_UC, string $userusersex) { return $user_UC != ""&& $user_UC != null$user_UC:$userusersex ; }
然后aspx上 <%= FixUserName ($user_UC,$userusersex ) %>

用js脚本可以实现
首先制作表单,用户名密码分别给予ID:user,pwd
提交按钮里面加上 onclick="javascript:ChkForm()"
然后在页面最后加上
<script>
function ChkForm()
{
if (form1uservalue='admin'|form1pwd='admin')
{
alert('验证通过!');
}
}
</script>

有多少种链接,就多少次数啊。。通过次数访问不同的页面呗。。
比如:你有三个不同的页面需要通过此点击以后显示,那你就设一个次数值,每次点击后,次数值加1,然后判断该值(假设该值变量为count,初始值为0)
public int getClickCount()
{
if(click)
count ++;
return count;
}
int count = getClickCount();
switch(count) {
case 0://第一次点击
break;
case 1://第二次点击
break;
case 2://第三次点击
break;
}
这是java的写法,不知道你网页开发的语言是怎么写的,大概就是这样的。

具体做法是:

<c:choose>
<c:when test="${条件}">
情况1:
</c:when>
<c:when test="${条件}">
情况2:
</c:when>
<c:otherwise>
否则。。。。。
</c:otherwise>
</c:choose>

所以实现了这种形式的判断。

JSP全名为Java Server Pages,中文名叫java服务器页面,其根本是一个简化的Servlet设计,它 是由Sun Microsystems公司倡导、许多公司参与一起建立的一种动态网页技术标准。JSP技术有点类似ASP技术,它是在传统的网页HTML(标准通用标记语言的子集)文件(htm,html)中插入Java程序段(Scriptlet)和JSP标记(tag),从而形成JSP文件,后缀名为(jsp)。 用JSP开发的Web应用是跨平台的,既能在Linux下运行,也能在其他 *** 作系统上运行。

它实现了Html语法中的java扩张(以 <%, %>形式)。JSP与Servlet一样,是在服务器端执行的。通常返回给客户端的就是一个HTML文本,因此客户端只要有浏览器就能浏览。

<script language="javascript">
var win;
function OpenWindow
{
win=windowopen("testhtm","test","");
}
function CheckWindow()
{
if(win!=null)
{
如果存在,则调用testhtm中的一个方法
}
else
{
如果不存在,则重新open testhtm,并调用testhtm中的那个方法
OpenWindow();//如果不存在,则重新open testhtm
}
}
</script>
To:top1
那就没办法啦因为只子窗口打开后只能在父窗口监测


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/13402234.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-07-29
下一篇 2023-07-29

发表评论

登录后才能评论

评论列表(0条)

保存