2013年9月12日星期四

GridView comes modify the function how to validate text box to enter ?

I used to do payroll GridView and modify the function to modify with their own wages, but do not know how to validate text box to enter , what characters can now submit a submission on the error , and how to modify the function GridView comes with added input text box verification , allowed only enter numbers , find us.


------ Solution ------- -------------------------------------
GridView1_RowUpdating event in the background to get to value, you can use regular expressions determine whether it is digital .
refer: http://weekzero.cnblogs.com/articles/401231.html
- ----- Solution --------------------------------------------
text box bound keypress event , call the js validation
function MustNumber ()
{if (((event.keyCode> = 48) && (event.keyCode <= 57)) | | (event.keyCode == 46)) {event.returnValue = true;} else {event.returnValue = false;} }
------ Solution --------------------------------------- -----
GridView- edit field - put the field into a template - and then put a text box + a validation controls
can automatically determine whether a number, if not a number , text boxes, followed by prompt
validation controls built in toolbar
http://www.cnblogs.com/_zjl/archive/2011/03/07/1974486.html
------ For reference only ----------- ----------------------------
verify if the front desk , you can use jquery to find the code shown in the textbox of the id, then inside the js validation .
------ For reference only -------------------------------------- -
do a pop-up window to modify , you did deal more trouble
------ For reference only ----------------------- ----------------
onkeypress = "inputkeypress2 (this)" Style = "text-align: right; padding-right: 3px;
padding-top: 5px; "MaxLength =" 15 "Width =" 100 "ID =" Money "Text = '<% # ; Eval ("Money")%> '
runat = "server">

/ / restrictions can only enter numbers and decimals and only after the decimal point two
function inputkeypress2 (inputobj) {
if (! inputobj.value.match (/ ^ \ d *? \.? \ d * ? $ / ) )
inputobj.value = inputobj.t_value;
else
inputobj.t_value = inputobj.value;
if (inputobj.value.match (/ ^ (?: \ d + (?: \. \ d +)?)? $ /))
inputobj.o_value = inputobj.value
if (/ \. \ d {2} $ /. test (inputobj.value)) ; event.returnValue = false
}
function inputkeyup (inputobj) {
if (! inputobj.value.match (/ ^ \ d *? \.? \ d * ? $ / ) )
inputobj.value = inputobj.t_value;
else
inputobj.t_value = inputobj.value;
if (inputobj.value.match (/ ^ (?: \ d + (?: \. \ d +)?)? $ /))
inputobj.o_value = inputobj.value
}
function inputblur (inputobj) {
if (! inputobj.value.match (/ ^ (?: \ d + (?: \. \ d +)? | \. \ d *?)? $ /))
inputobj.value = inputobj.o_value;
else {
if (inputobj.value.match (/ ^ \. \ d + $ /))
inputobj.value = ; 0 + inputobj.value;
if (inputobj.value.match (/ ^ \. $ / ) )
inputobj.value = ; 0 ;
inputobj.o_value = inputobj.value
}
}
------ For reference only ----------------- ----------------------


good, controls control Favourites
------ For reference only --------------------------- ------------


this better directly in the GridView verified , no brain operation

没有评论:

发表评论