Java script validations
-
Friday, May 02, 2008 1:53 PM
We are using both server side and client side validations in the application.
Scenario 1:
The application should display a error message on entering alphabets and clicking on Save button.
This is a client side validation message.
Scenario 2:
The application should displays a error message on entering more than 5 digits and clicking on Save.
Here, client server validation message is displayed.
I am not able to automate the scenario involving client side validations. The script on playing back, bypasses the client side side validations. (i.e the script saves the data with alphabets in scenario 1)
All Replies
-
Saturday, February 04, 2012 5:14 PM
You need to add an event with save button named onclientClick =" return JavascriptMethodName()"
within the method you need to count alphabet. if count is greater that 5 then you alert the message and return false, otherwise return true. It is now working.
-
Tuesday, February 07, 2012 10:36 AMmake "return true;"
-
Thursday, February 09, 2012 10:24 AM
Below code will help you to check those two conditions
function doSomething(e) { if (e.keyCode > 64 && e.keyCode < 91) { alert('Please enter character other than alphabet'); return false; } } function checkLength(a) { if (a.length > 5) { alert('Please enter maximum of 5 characters'); return false; } }
-
Monday, February 13, 2012 5:51 AM
You need to set onclick attributes of the button like
btnSave.Attributes.Add("onclick","return somefunction();");

