public static string GetInputControlsNameAndValueInPage(string strPage)
{
string strRegExPatten = "<s*input.*?names*=s*"(?<Name>.*?)".*?values*=s*"(?<Value>.*?)".*?>";
Regex reg = new Regex(strRegExPatten, RegexOptions.Multiline);
MatchCollection mc = reg.Matches(strPage);
string strTemp = string.Empty;
foreach (Match m in mc)
{
strTemp = strTemp + m.Groups["Name"].Value + "=" + m.Groups["Value"].Value + "&";
}
int n = strTemp.Length;
strTemp = strTemp.Remove(n - 1);
return strTemp;
}
Tag Archive for input
clean user input data ( GET, POST, COOKIE )
<?php
function clean($value)
{
if (get_magic_quotes_gpc()) $value = stripslashes($value);
if (!is_numeric($value)) $value = mysql_real_escape_string($value);
return $value;
}
array_walk($_GET,'clean');
array_walk($_POST,'clean');
array_walk($_COOKIE,'clean');
extract($_GET,EXTR_PREFIX_ALL,'get');
extract($_POST,EXTR_PREFIX_ALL,'post');
extract($_COOKIE,EXTR_PREFIX_ALL,'cookie');
?>
form
.hazte-socio.alta-form fieldset { border: 0; margin: 0 0 20px 0; padding: 0 }
.hazte-socio.alta-form legend { margin: 0 0 12px 0; * margin-left: -5px; padding: 0 }
.hazte-socio.alta-form legend span {
display: block;
width: 720px;
border-bottom: 1px solid #ecf0f5;
padding-bottom: 1px;
color: #064598;
font-size: 1.4em;
font-weight: bold;
}
/* Etiquetas */
.hazte-socio.alta-form label {
display: block;
position: relative;
width: 170px;
height: 26px;
position: relative;
color: #333;
font-size: 1.2em;
text-align: right;
}
/* Campos */
.hazte-socio.alta-form label input,
.hazte-socio.alta-form label select {
position: absolute;
top: -2px;
left: 181px;
font-weight: bold;
}
Toggles instructional and default copy text and styles
/**
* Add instructional copy support for text fields and text area.
* The method will clear the copy, and swap styles.
*
* @param textField the text element that will be enhanced.
* @param copyClass class used for instructional copy
* @param noCopyClass class used for plain text
*/
function sl_addClearCopyListeners (textField, copyClass, noCopyClass){
// set default value in the object itself
textField.originalCopy = textField.value;
textField.copyClass = copyClass;
textField.noCopyClass = noCopyClass;
// add listiners
textField.onfocus = function(){
if (this.value == this.originalCopy){
this.value = '';
sl_replaceClass(this, this.copyClass, this.noCopyClass);
return false;
}
return true;
};
textField.onblur = function(){
if (this.value == ''){
sl_replaceClass(this, this.noCopyClass, this.copyClass);
this.value = this.originalCopy;
return false;
}
return true;
};
};
/**
* Replace a class with another, leaving other classes untouched.
* If the class does not exist, nothing will happen.
*
* @param domElement the text element that will be enhanced.
* @param oldClass class to replace
* @param newClass the replacement class
*/
function sl_replaceClass(domElement, oldClass, newClass){
var elementClass = '' + domElement.className;
// save some work, avoid flashing
if (elementClass.indexOf(oldClass) > -1){
elementClass = elementClass.replace(oldClass , newClass);
domElement.className = elementClass;
}
}
Category: Uncategorized |
Tags: area, copy, field, input, instructional, javascript, text, textarea, TextField
File
<div class="file"><label for="$1">$2:</label><input type="file" id="$1" name="$1" /></div>$3
Radio
<div class="radio"><input type="radio" name="$1" id="2" ${3:checked="checked"} /><label for="$1">$4</label></div>$5
Checkbox
<div class="checkbox"><input type="checkbox" id="$1" name="$1" ${2:checked="checked"} /><label for="$1">$3</label></div>$4
text
<div class="textfield"><label for="$1">$2:</label><input type="text" id="$1" name="$1" title="${3:Enter your ${2/./l$0/} here}" value="$4" /></div>$5
Copy/repeat input form values
function copyDown(nm) {
// written by Daniel P 3/20/07
// repeat the values of the first row of a column down the whole column
// special case for sku: value in incremented as you go down.
// also, values are only filled in for rows that have a sku filled in
var lastskuindex = document.getElementById('lastindex');
var firstitem = document.getElementById(nm+'0');
z = firstitem.value;
for ( i=1; i<=lastskuindex.value; i++ ) {
//window.receivelist["Received"+i].checked=true;
if (nm=='SKUCode' && z!='') { // special case for skucode (when not blank)
z++; // increments the sku
zstring = z.toString();
if ( zstring.length == 1 ) zstring='00000'+zstring;
if ( zstring.length == 2 ) zstring='0000'+zstring;
if ( zstring.length == 3 ) zstring='000'+zstring;
if ( zstring.length == 4 ) zstring='00'+zstring;
if ( zstring.length == 5 ) zstring='0'+zstring;
document.getElementById(nm+i).value = zstring;
} else {
if (document.getElementById('SKUCode'+i)) { // if there's an editable skucode (only add page)
if (document.getElementById('SKUCode'+i).value != '') { // only update this row if sku is filled in for this row
document.getElementById(nm+i).value = firstitem.value;
}
} else { // not add page, so we just update regardless of if sku is filled in
document.getElementById(nm+i).value = firstitem.value;
}
}
} // looping down the rows
}
clear form field on first focus
<html>
<head>
<title>Clear form field on initial focus</title>
<script type="text/javascript">
function clearOnInitialFocus ( fieldName ) {
var clearedOnce = false;
document.getElementById( fieldName ).onfocus = (function () {
if (clearedOnce == false) {
this.value = '';
clearedOnce = true;
}
})
}
window.onload = function() { clearOnInitialFocus('myfield');
</script>
</head>
<body>
<h1>Clear form field on initial focus</h1>
<input name="myfield" id="myfield" value="default message">
</body>
</html>