1.Textbox: While using .validateNotNumber(TextBox),the TextBox is accepting alphanumeric, which shld nt be the case, as i want to have only NAME inside a text box n nt 'abc1234', it shld accept only 'abcd'. also if the textbox handles NUMBERS only using keyuphandler, it shld only accept '1234' n not 'a1234', which is the current behaviour now. It accepts 'a1234'. meaning, the first character is nt validated properly, if we enter 'a', it does nt validate, bt if we enter'a1234', it validates correctly after the first digit, i.e, it throws err only after the i/p of 2nd character in the text box area of a NUMBER type!
function doGet()
{
var app = UiApp.createApplication();
var panel = app.createVerticalPanel();
var grid = app.createGrid(11, 10).setId('maingrid');
var nameLabel = app.createLabel("Name:");
var nameTextBox = app.createTextBox().setName('name').setId('name');
var nameRequiredLabel = app.createLabel("*").setId('namerequired').setStyleAttribute("color", "red");
var requiredFieldLabel = app.createLabel("*-Required Field").setId('requiredfield').setStyleAttribute("color", "red");
grid.setWidget(0, 0, nameLabel).setWidget(0, 1, nameTextBox).setWidget(0, 2, nameRequiredLabel)
.setWidget(9, 2,requiredFieldLabel);
var invalidText=app.createClientHandler().validateNumber(nameTextBox)
.forTargets(nameTextBox).setStyleAttribute("color", "red")
.forTargets(nameRequiredLabel).setText('Please Enter a Valid Name.').setStyleAttribute("color", "red").setVisible(true);
var validText=app.createClientHandler().validateNotNumber(nameTextBox)
.forTargets(nameTextBox).setStyleAttribute("color","black")
.forTargets(nameRequiredLabel).setText('*').setStyleAttribute("color", "red").setVisible(true);
nameTextBox.addKeyUpHandler(invalidText).addKeyUpHandler(validText);
panel.add(grid);
app.add(panel);
return app;
}
Note: I used .validateInteger(TextBox) and .validateNotInteger(TextBox) also, But its too giving the same o/p as above(alphanumeric).
2.DateBox: It shld accept only DATES format n shld nt be possible to enter any other characters after the DATE is picked. Fr eg. If i select a DATE '14-08-2012', it shld nt accept any other characters beyond this length, like '14-08-2012abc123', literally there shld be a method to validate/restrict the field, if it's any REAL DATE format n nt just a DATE+TEXT. Accidentally, the user may enter any unwanted text in the DATE box, which we may need to avoid! We may need a '.validateDateLength()' to handle this issue!
3.Drop Down box: in any given drop box, the option 'SELECT' will b the first option to intimate us to select the option required from the drop down list I used .validateMatches("SELECT") and .validateNotMatches("SELECT"), to check if any option is selected by the user or not, which means i want to ensure the user has selected something from the drop down box n NT just left tht option UNSELECTED. Bt, it doesn't seem to validate the Matches.
4.Check Box,Radiobutton: Fr these 2 controls, i just want to ensure tht the user has SELECTED any of my RADIOS or any of my CHECKBOXES, if those particular RADIO's are nt selected by the user, the control shld pass an err, saying tht 'PLZ SELECT THE RADIO/CHECK BOX OPTION TO PROCEED FURTHER'. What is the right method to do this?
Eg. script
var valid = app.createClientHandler()
.validateNumber(number)
.validateNotInteger(text)
.validateEmail(email)
.validateNotMatches(listbox, 'select')
.forTargets(submit).setEnabled(true)
.forTargets(number,text,email).setStyleAttribute("color","black")
.forTargets(numberrequired,textrequired,emailrequired).setText('*')
.setStyleAttribute("color","red").setVisible(true);
I used the above code for the 'SUBMIT' Button enable and disable concept, In this itself the ListBox is not validating correctly the 'SELECT' option.
So, basically, I want all these validation to function properly, so tht I cn make my 'SUBMIT/SAVE' ENABLED, until all my above controls are checked/validated, which ensure tht the user has entered/selected all the options properly & is in the required format to proceed to the SUBMIT page.
Hopefully, I m clear, plz dont hesitate to ask me if I m wrong/unclear somewhere!
Please guide me, Thanks & Regards, chocka.