Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am developing the search web page in my Application. We are entering or selecting text of asp.net controls when pressing the enter key then fire the Search Linkbutton in my page. I was set the DefaultButton for forms and panel control in search page. It works fine. But here problem is i have a textbox with validations and set the property of DefaultButton for panel or Forms in Search page. Validation doesn't working for textbox.

For Example: I have a textbox . It can take only Numbers and using event is onkeypress="return onlyNumbers()". wrote the validaion at client side. the main problems is doesn't work validaions. without validation it is fine.
Because my application is coming to deadline, that is the main reason.
Could you help me any one please.........
Posted
Updated 7-Aug-12 18:49pm
v18
Comments
CH Guravaiah 18-Jul-12 2:39am    
hi
CH Guravaiah 20-Jul-12 1:29am    
Please any one help me.......

1 solution

This means your validation logic is not correct. Three ways:
1. Use Custom or RegularExpression validator to handle only numbers OR
2. Use onBlur client side event of the textbox to raise the validation issue alert OR
3. Use masked textbox that will allow only integers to be entered in it.

Setting DefaultButton just submits the page(on pressing enter key) with the associated button click event.
 
Share this answer
 
Comments
CH Guravaiah 18-Jul-12 5:25am    
Before set the DefaultButton of Panel or Form for Search LinkButton , The Client Side Validation working Fine..... Please help me.
Sandeep Mewara 18-Jul-12 5:52am    
What I said, try that. Your implementation for validation has flaw right now through which default button is able to get through. (not a problem of default button here!)
CH Guravaiah 18-Jul-12 9:25am    
please understand my problem. without setting DefaultButton it's fine.


this is javascript Function: function onlyNumbers(evt) {

var e = event || evt; // for trans-browser compatibility
var charCode = e.which || e.keyCode;

if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;

else
return true;
}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900