-----Ursprungliche Nachricht----- Von: James Mitchell [mailto:[EMAIL PROTECTED] Gesendet: Donnerstag, 20. November 2003 12:30 An: Struts Users Mailing List Betreff: Re: URGENT :: Disable enter key in HTML:FORM by using onKeyPress func tion
On Thu, 20 Nov 2003, Chawla, Yogesh wrote: > Hi, > > In normal forms, we can disable enter key by calling onKeyPress() function > in the form tag. > However, this is not supported in the <html:form> definition for Struts. > > Can anybody give a solution to this ... Your best bet for stopping the user from submitting a form with JavaScript is to handle it in the form tags onsubmit attribute. Here's an example from a recent app I'm working on: I needed a way to make sure that users entered a minimum of 3 (or some configurable value) characters when performing a search. The problem is that it can be 3 characters from any combination of 3 fields. <html:form action="/manageUsers" onsubmit="return doMyValidation(this)" focus="view.registration.security.userName"> ...and at the bottom of the page I do this... <script language="JavaScript"/> function doMyValidation(form){ u = form.elements['view.registration.security.userName'].value.length; f = form.elements['view.registration.personal.firstName'].value.length; l = form.elements['view.registration.personal.lastName'].value.length; if (u + f + l < <bean:message key="validation.min.search.chars"/>){ alert('<c:out value="${msg}"/>'); return false; } return validateSearchForm(form); } </script> <html:javascript formName="searchForm" dynamicJavascript="true" staticJavascript="true"/> Hi, within the bean:write tag, i am able to format a property like this: <bean:write name="myRendevous" property="date" format="dd.MM.yyyy"/> Is there a chance to format a property within the html:text tag the same way, like: <html:text name="myRendevous" property="date" format="dd.MM.yyyy" /> ??? Thanks in advance for your help :o) Mario Gleichmann --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]