如何在单独的js文件函数中获取内容的页面文本框值 [英] How can I get content's page textbox value in separate js file function

查看:143
本文介绍了如何在单独的js文件函数中获取内容的页面文本框值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在单独的js文件中保留用于检查内容页面上的空白文本框的验证码。



我有以下问题:



1.必须在单个内容页面上明确显示,因此不能将其添加到母版页中,因为它会在所有内容页面中不必要地反映



2.如何在单独的js文件中获取内容的页面值。



请提供包含源代码的适当解决方案

I want to keep validation code for checking blank textbox on content page in separate js file.

I have following problems:

1. It has to occur explicitly on single content page so can't add it in master page since it will reflect unnecessarily in all content pages

2. How to get content's page value in function within separate js file.

Please provide appropriate solution with source code

推荐答案

解决方案是在< head>内的母版页中添加ContentPlaceholder标记,以便您可以添加每页附加脚本。



不确定内容页面值是什么意思。假设你想要一个文本框来验证,你使用与任何其他验证相同的技术:

通过id或其他各种元素找到单个特定文本框,可以返回多个文本框: br />
javascript jQuery

--------------------------------- ----------

getElementById(id)||
The solution is to add ContentPlaceholder in master page within <head> tag so that you can add per page additional scripts.

Not sure what do you mean by "contents page value". Assuming you want to take a text box to validate, you use the same technique as any other validation:
either find the single particular textbox via id or other various elements which can return more then one textbox:
javascript jQuery
-------------------------------------------
getElementById("id") ||



(#id)

getElementByTagName ||
("#id") in jQuery
getElementByTagName ||


(input)

getElementByName ||
("input")
getElementByName ||


这篇关于如何在单独的js文件函数中获取内容的页面文本框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆