The validation for the pattern attribute will not prevent writing incorrect information into the field, but it will prevent submitting the form. The element also has an oninvalid event that will be called when the validation fails during the submit.
Alternatively, you can also use the CSS selectors :valid and :invalid to provide instant visual feedback.
Fiddle showing both (based on Jerry’s fiddle from the comments): http://jsfiddle.net/bHWcu/1/
<form onsubmit="alert('Submitted');">
<input dir="ltr" type="text" title="Enter numbers only." pattern="[\d]{9}" id="uid" name="1" placeholder="Enter UID" required="'required'" class="required placeholder" maxlength="9" autocomplete="off" />
<input type="submit" value="Submit" />
</form>
Note that any client-side validation should only be used for fast feedback to improve the user experience. The actual validation should always be done server-side, as the client-side validation can easily be cheated.