html - input[type="file"] check existence of file attachment with css -


it's not js question, looking clear css solution if it's possible.

for radio button or checkbox can use :checked pseudo class:

input{   % styles % } input:checked{   % styles % } 

are there tricks checking if file attachment exists css?

(updated, due misunderstanding question)

it possible check if file attached using attribute required.

see: http://jsfiddle.net/1ua59jt1/1/

html:

<input id="file" type="file" name="fileselect" required="required" /> 

css:

#file:valid { color: green; } #file:invalid { color: red; } 

but can never validate, if "correct" file selected way. can check if or if not file selected @ all.


// completion update:

the required attribute html5. please aware not browsers support this: http://www.w3schools.com/tags/att_input_required.asp

that means trusted way client side validation using javascript. if want so, recommend using novalidate attribute on form disable browsers default validation (http://www.w3schools.com/tags/att_form_novalidate.asp).

but always use server-side validation, too. can never make sure user has enabled jaavscript or hasn't manipulated javascript. best way validate values on side have control over: server, i.e. action form sends data to.


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -